Dlookup problems (was my Dlookup hell)

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.
 
T

Treebeard

Try

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

Kavvy

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
 
T

Treebeard

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
 

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

Similar Threads

my Dlookup hell 3
DLookup not recognizing variable 5
dlookup 2
DLookup or Code 2
DLookup 4
VBA works in orignal but fails in copy of database 1
Help with DLookup 4
DLookup Missing RecordSource Question 2

Top