my Dlookup hell

K

Kavvy

Could you tell me what is wrong with this line

Me!Department = DLookup("Sub-Department", "QRY Employees", "Payroll No =
Forms!FRM Jobs!Payroll No")

The error message is

'Syntax error' missing operator in query expression.

Is it the fact there are spaces?
Thanks
K
 
A

Allen Browne

Concatenate the value of the control onto the 3rd argument.
The names with spaces must also be enclosed in square brackets:

Me!Department = DLookup("Sub-Department", "QRY Employees", _
"Payroll No = " & Forms![FRM Jobs]![Payroll No])

If PayrollNo is actually a Text field, you need extra quotes:

Me!Department = DLookup("Sub-Department", "QRY Employees", _
"Payroll No = """ & Forms![FRM Jobs]![Payroll No] & """")
 
T

Treebeard

And brackets around payroll no.

"[Payroll No] = " & Forms![FRM Jobs]![Payroll No]



Geoff said:
Try putting brackets around FRM Jobs maybe?

DLookup("Sub-Department", "QRY Employees", "Payroll No =
Forms![FRM Jobs]!Payroll No")

Kavvy said:
Could you tell me what is wrong with this line

Me!Department = DLookup("Sub-Department", "QRY Employees", "Payroll No =
Forms!FRM Jobs!Payroll No")

The error message is

'Syntax error' missing operator in query expression.

Is it the fact there are spaces?
Thanks
K
 

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