Compiler error problem with SQL in VBA

  • Thread starter Thread starter ruchie
  • Start date Start date
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?
 
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
..
 
Back
Top