What's wrong with this query (1 Viewer)

exaccess

Registered User.
Local time
Today, 21:48
Joined
Apr 21, 2013
Messages
287
Code:
strSQL = "INSERT INTO [" & dest & "] ([LastName], [FirstName], [Language]," & _
    " [Email], [Associatiom]) " & "SELECT FROM [" & Origin & "] ([LastName], [FirstName]," & _
    " [Language], [Email], [Federation])"
This is a query that I have to use to copy Origin = TransNMTbl to dest="TransTbl. Both source and destination can be variables. The column names and sizes are exactly he same except for the last one where only the name changes from Federation to Association. I get syntax error when I try to run it. What is the solution? Help please.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:48
Joined
May 7, 2009
Messages
19,169
should be:


strSQL = "INSERT INTO [" & dest & "] ([LastName], [FirstName], [Language], , [Associatiom]) SELECT [LastName], [FirstName], [Language], [Email], [Federation] FROM [" & Origin & "]"
 

exaccess

Registered User.
Local time
Today, 21:48
Joined
Apr 21, 2013
Messages
287
should be:


strSQL = "INSERT INTO [" & dest & "] ([LastName], [FirstName], [Language], , [Associatiom]) SELECT [LastName], [FirstName], [Language], [Email], [Federation] FROM [" & Origin & "]"[/QUOTE]

Dear Friend. Unfortunately it says syntax error in from phrase. Does not work.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:48
Joined
May 7, 2009
Messages
19,169
this is one line only:

strSQL = "INSERT INTO [" & dest & "] ([LastName], [FirstName], [Language], , [Associatiom]) SELECT [" & Origin & "].[LastName], [" & Origin & "].[FirstName], [" & Origin & "].[Language], [" & Origin & "].[Email], [" & Origin & "].[Federation] FROM [" & Origin & "]"
 

exaccess

Registered User.
Local time
Today, 21:48
Joined
Apr 21, 2013
Messages
287
this is one line only:

strSQL = "INSERT INTO [" & dest & "] ([LastName], [FirstName], [Language], , [Associatiom]) SELECT [" & Origin & "].[LastName], [" & Origin & "].[FirstName], [" & Origin & "].[Language], [" & Origin & "].[Email], [" & Origin & "].[Federation] FROM [" & Origin & "]"[/QUOTE]

I am copying the statement exactly on one long line. This did not work either.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:48
Joined
May 7, 2009
Messages
19,169
instead of running the wuery put it in msgbox, then you will know what is the problem
 

isladogs

MVP / VIP
Local time
Today, 20:48
Joined
Jan 14, 2017
Messages
18,186
Assuming that you posted your exact code, you have mis-spelled 'Association' with an 'm' at the end.

If that's not the problem, try typing debug.print line to view the output in the immediate window
 

exaccess

Registered User.
Local time
Today, 21:48
Joined
Apr 21, 2013
Messages
287
Yes Association is the correct one, but that is only typo. In my code I corrected it. I'll try one of those techniques.
 

exaccess

Registered User.
Local time
Today, 21:48
Joined
Apr 21, 2013
Messages
287
I had an application problem. At the extreme side my Origin and dest tables were the same. Now I have this Not enough memory 7 problem. But I'll have to start another thread. Many thanks.
 

Users who are viewing this thread

Top Bottom