Advertisement

06.02.2008 at 08:39PM PDT, ID: 23451999
[x]
Attachment Details

Type mismatch error occurs when using SQL statement in VBA

Asked by angie_angie in Access Coding/Macros

Tags: MS Access, VBA

Here is the original question that I posted previously:

I want to update tblTemplate with data from tblSource (see attachment).
The task is to append all the records from the selected fields in tblSource to tblTemplate. And the data type of tblSource.DateA & .DateB is TEXT, but corresponding fields (tblTemplate.Date1 & .Date2) is DATE (with fix format as e.g. 03-Jan-08).
I have already have some code, could someone help to modify these code to suit the above requirement (I prefer to use SQL statement) ?

Now after I tried the SQL code below given by an expert, it works just fine as an append query. But when I tried to incoorporate the SQL statement into my VBA codes. A type mismatch error occurs with the SQL statement.

Can anyone help on this issue?

Thank you very much.


Start Free Trial
1:
2:
3:
4:
INSERT INTO tblTemplate ( [Number], Date1, Date2 )
SELECT tblSource.Number, (Mid([DateA],9,2) & "-" & Mid([DateA],6,2) & "-" & Left([DateA],4)) AS Expr1, (Mid([DateB],9,2) & "-" & Mid([DateB],6,2) & "-" & Left([DateB],4)) AS DataA
FROM tblSource, tblTemplate
WHERE (((tblSource.Number) Not Like ""));
Attachments:
 
sample append query given by jppinto
 
[+][-]06.02.2008 at 09:09PM PDT, ID: 21697513

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 09:15PM PDT, ID: 21697531

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Access Coding/Macros
Tags: MS Access, VBA
Sign Up Now!
Solution Provided By: capricorn1
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.02.2008 at 09:21PM PDT, ID: 21697547

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 09:33PM PDT, ID: 21697571

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208