my Dlookup hell

  • Thread starter Thread starter Kavvy
  • Start date Start date
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
 
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] & """")
 
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
 
Back
Top