Compiler error problem with SQL in VBA

R

ruchie

can anyone please tell me what is wrong with the SQL statement in the
end:

Dim AudID As Integer
Dim audit As String

AudID = (Me.audits.ItemData(i))

audit = DoCmd.RunSQL "SELECT [Audit] FROM tblauditUniv WHERE [AuditID]
= AudID;"

I am constantly getting Compiler error : Expected end of statement.
can someone guide me on where I am going wrong?
 
J

John Spencer

Strange message.

You should be getting a different error

DoCmd.RunSQL requires an action query - one that adds or deletes or updates
records. It will error with a SELECT query.

If you are trying to get the value you might use the DLookup function

Audit = DLookup("Audit","tblAuditUniv","AuditID=" & AudID)


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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