DoCmd.RunSQL INSERT INTO Syntax

Geoff Codd

Registered User.
Local time
Today, 17:42
Joined
Mar 6, 2002
Messages
190
Hi there,

I'm trying to get the following to work but i'm having syntax problems

DoCmd.RunSQL ("INSERT INTO [tblSatchwell_Trend_Logs_(Data)] ( Point_ID, [Date], [Time], Reading )" _
& "SELECT Points.Id AS Point_ID, [tblSatchwell_Trend_Logs_(Temp)].Date, [tblSatchwell_Trend_Logs_(Temp)].Time, [tblSatchwell_Trend_Logs_(Temp)].Value AS Reading " _
& "FROM [tblSatchwell_Trend_Logs_(Temp)] INNER JOIN Points ON [tblSatchwell_Trend_Logs_(Temp)].Mnemonic = Points.Import_Link_Code_Profile" _
& "ORDER BY Points.Id, [tblSatchwell_Trend_Logs_(Temp)].Date, [tblSatchwell_Trend_Logs_(Temp)].Time;")

any help would be appreciated

Thanks
Geoff
 
i can't change them, it runs fin as a query, i just want to get rid of some of the smaller queries to clean things up a bit

thanks
geoff
 
Value is also a reserved word. ;)

Code:
Points.Import_Link_Code_Profile"

is what you have

  • surround this field with square brackets;
  • put a space on the end or it will asume ORDER (next line) is all one word when commected with profile (i.e. ProfileORDER)

Code:
Points.[Import_Link_Code_Profile] "
 
Tony Hine said:
Thats a valuable piece of info, I'll remember that...

Any VBA Keyword is a reserved word. If you set a reference to a new library then every keyword that applies to that library becomes a reserved word.

i.e. if I set a reference to Excel then ActiveCell is reserved.
 

Users who are viewing this thread

Back
Top Bottom