Syntax error (missing operator) in query expression

W

Wind54Surfer

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
 
D

Duane Hookom

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?
 
W

Wind54Surfer

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
 
D

Duane Hookom

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

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