Help with DLookup

G

Guest

I have the following lookup in the 'After Update' event of a field (Order
Line Status)...


Dim TFlag As Variant

TFlag = DLookup("[OrderLineStatusClosed]", "tbl_OrderLineStatus",
"[OrderLineStatus] = " & Forms!frm_OrderLines!OrderLineStatus)

Me.OrderLineClosed = TFlag
Me.OrderLineStatusdate = Now

The intention is to update the field OrderLineStatus (drop down) and then
lookup to a table of Order Line Status's and get the value in the
OrderLineStatusClosed field(boolean) and push this into a field on the form,
so the record is set to open or closed as nessecary

With the above I am getting the error message...
'Syntax Error (missing operator) in query expresion '[OrderLineStatus]
= Open'

where Open is th value in the OrderLineStatus field

What am I doing wrong?
 
D

Douglas J. Steele

It sounds as though OrderLineStatus is a text field. If that's the case, you
need quotes around the value you're using:

"[OrderLineStatus] = """ & Forms!frm_OrderLines!OrderLineStatus & """")

or

"[OrderLineStatus] = '" & Forms!frm_OrderLines!OrderLineStatus & "'")

Exagerated for clarity, the second option is


"[OrderLineStatus] = ' " & Forms!frm_OrderLines!OrderLineStatus & " ' ")
 

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