Help with syntax error

A

Al

I am getting a syntax error msg on the following sql statement:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String, strFieldName As String

Set db = CurrentDb()

strFieldName = Me.AuditTest.Name

strSQL = "INSERT INTO audCapital_Projects_Field (audType, audDate, audUser,
RevisedField, RevisedValue) " & _
"VALUES ('EditFrom' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, "
& strFieldName & ", " & AuditTest & ")"
db.Execute strSQL
 
A

Al

Thank you, right on the money:)

Marshall Barton said:
Don't use alsias name in the VALUES clause.

strFieldName needs to be enclosed in quotes. So does
AuditTest if the RevisedValue field is a Text field.

"VALUES ('EditFrom', Now(), NetworkUserName(), '" _
& strFieldName & "', '" & AuditTest & "')"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top