Dlookup problems (was my Dlookup hell)

  • Thread starter Thread starter Kavvy
  • Start date Start date
K

Kavvy

Hi,

Thanks to those who helped me out with my last query, the changes make sense
to me but I am now getting a new error which is confusing!

Run-time error 2471

The expression you entered as a query parameter produced this error: 'The
object doesn't contain the Automation object 'Sub."

This is my code which executes on a After Update event

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

Thanks for your help!
K.
 
Try

DLookup("[Sub-Department]", "[QRY Employees]", "[Payroll No] = "
& Forms![FRM Jobs]![Payroll No])
 
Treebeard said:
Try

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

It works dammit!!! :D

I found this confusing because the first part of the query worked if I
simply put something like this

DLookup("Sub-Department", "QRY Employees", "[Payroll No] = 10")

Which would put 10 into the field, but then adding the field search also
required the [] brackets as you pointed out...

Thanks again :)
K
 
In the future don't put spaces or minus signs as names of your fields or
tables.
;-)
jack


Kavvy said:
Treebeard said:
Try

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

It works dammit!!! :D

I found this confusing because the first part of the query worked if I
simply put something like this

DLookup("Sub-Department", "QRY Employees", "[Payroll No] = 10")

Which would put 10 into the field, but then adding the field search also
required the [] brackets as you pointed out...

Thanks again :)
K
 
Back
Top