Inserting values into table with SQL

spudracer

Here and there
Local time
Today, 18:12
Joined
Jul 1, 2008
Messages
199
I'm trying to insert a set of values into a table using SQL.

Here's my code:
Code:
DoCmd.RunSQL "INSERT INTO tblAuditTrail([DateTime], [UserName], [RecordID], [Action], [FieldName], [OldValue], [NewValue])VALUES (" & Now() & ", " & User & ", & Me.CSM & ", " & 'EDIT' & ", " & 'Location' & ", " & Me.txtTranFrom & ", " & Me.txtTranTo & ");"

However, this returns a compile error.

I reference User as Environ("USERNAME") earlier in the code. Everything else pulls from the current table ("tblInventory").

I'm lost, since I've never attempted to use SQL in VBA.
 
Here's what I see:

You need a space before "VALUES"
Why do 'Edit' and 'Location' have single quotes around them?
Are all your other values numeric? Because you are inserting them like numbers.
 

Users who are viewing this thread

Back
Top Bottom