dynamic append query (1 Viewer)

btamsgn

Member
Local time
Today, 15:04
Joined
Nov 8, 2010
Messages
51
Hi,

I'd like to use vba to make a dynamic append query with button "update" on form1. however It's error.

I looking forward to receive your help, thanks!


Thanks&Regards,
Tam Binh
 
Last edited:

John Big Booty

AWF VIP
Local time
Today, 18:04
Joined
Aug 29, 2005
Messages
8,262
Welcome to the forum.

I'm presuming the error is in the SQL statement. Each line of the SQL statement must be enclosed in double Quotes (") and each line, excluding the last must end with " & _, try that in your SQL statement and see how you go.

Note: At the end of a each line be sure to leave a space before closing with " & _
 

John Big Booty

AWF VIP
Local time
Today, 18:04
Joined
Aug 29, 2005
Messages
8,262
...so you code should look something like;
Code:
STRSQL = "INSERT INTO S_test ( ID, NPL, DVT, A, B, C, D, E, F, G, H, I, J, K, L, M, O, P, TONG ) " & _
"SELECT CR5ADM.ID AS ID, CR5ADM.NPL AS NPL, CR5ADM.DVT AS DVT, CR5ADM.[intn] AS A, CR5ATLHH.[intn] AS B, CR5ANCAU.[intn] AS C, CR5ADM.[intn1] AS D, CR5ATLHH.[intn1] AS E, CR5ANCAU.[intn1] AS F, CR5ADM.[intn2] AS G, CR5ATLHH.[intn2] AS H, CR5ANCAU.[intn2] AS I, CR5ADM.[intn3] AS J, CR5ATLHH.[intn3] AS K, CR5ANCAU.[intn3] AS L, CR5ADM.[intn4] AS M, CR5ATLHH.[intn4] AS O, CR5ANCAU.[intn4] AS P " & _
"FROM (CR5ADM INNER JOIN CR5ATLHH ON CR5ADM.ID = CR5ATLHH.ID) INNER JOIN CR5ANCAU ON CR5ADM.ID = CR5ANCAU.ID;"

Caveat emptor; I've not tested to see if the actual code will do what you wish, I've simply correct the use of double quotes and line breaks
 

btamsgn

Member
Local time
Today, 15:04
Joined
Nov 8, 2010
Messages
51
Hi John Big Booty,

Thanks for yr reply.

However my code didn't run.

Pls check & repair my code to run dynamic append query.

Thanks&Regards,
Tam Binh
 

Users who are viewing this thread

Top Bottom