Syntax error (missing operator) in query expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

That is the error I get in the following Function and can't figure out why.
Access 2003
--------------------------------------------------------------------------
Function build_sql(Scheduled As String, operation As String) As String
build_sql = "Insert Into tblJobScheduleAuditLog Values ("
build_sql = build_sql & Scheduled & ", "
build_sql = build_sql & "'" & _
DLookup("JobDate", "JobSchedule", "Scheduled=" & _
Scheduled) & "', "
build_sql = build_sql & "'" & _
DLookup("Status", "JobSchedule", "Scheduled=" & _
Scheduled) & "', "

build_sql = build_sql & "'" & operation & "', "
build_sql = build_sql & "#" & Now() & "#)"
End Function
 
Can you tell us which line causes the error? Your declarations suggest
Scheduled is a string yet you seem to treat it like a number in the
DLookup()s.

Have you tried setting a breakpoint so you can step through your code and
check values?
 
The eror is at:
----------------------------------------------------------
build_sql = build_sql & "'" & _
DLookup("JobDate", "JobSchedule", "Scheduled=" & _
Schedule_d) & "', "
----------------------------------------------------------

I don't understand what you mean by treating "Scheduled as a number"?

Thanks a lot,
Emilio
 
If Scheduled is a text field, then you need to delimit
build_sql = build_sql & "'" & _
DLookup("JobDate", "JobSchedule", "Scheduled=""" & _
Scheduled & """") & "', "
 
Back
Top