Another DLookup question

J

JMorrell

If I had more hair I would be pulling it out now.

I'm having a brain freeze on this DLookup. Can someone please tell me why
it fails (#Error)?

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = & [boxPubID] &")

PubID is an autonumber PK in table Inventory and boxPubID is an unbound
control on a form.

many tia,
 
D

Dave M

If [boxPubID] is a control on a form, it persumably holds a value like 42,
and what your DLookup really should say is

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = 42")

for that particular instance. To make it general, you need to refer to the
control outside of the string, like this


=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = " & [boxPubID] )
 
J

JMorrell

Thanks for the reply. I had tried this exact syntax for the dlookup before.
Tried it again and am _still_ getting the #Error message in the control. I
think I've looked just about everywhere for something else that is keeping
this from working. Here's the rundown on my form;

form is based on a query, (SELECT Requests.PubID,
Inventory.NameOfPublication, Requests.Out, Inventory.Available FROM Requests
INNER JOIN Inventory ON Requests.PubID = Inventory.PubID;)
data entry setting = yes.

What am I missing here? Thanks for the help.
JMorrell



Dave M said:
If [boxPubID] is a control on a form, it persumably holds a value like 42,
and what your DLookup really should say is

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = 42")

for that particular instance. To make it general, you need to refer to the
control outside of the string, like this


=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = " & [boxPubID] )


JMorrell said:
If I had more hair I would be pulling it out now.

I'm having a brain freeze on this DLookup. Can someone please tell me why
it fails (#Error)?

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = & [boxPubID] &")

PubID is an autonumber PK in table Inventory and boxPubID is an unbound
control on a form.

many tia,
 
M

margaret bartley

Take a look at how you've named the text fields that hold data in your form.

Sometimes, if you change the default names, or change the data, and keep
the default names, queries that refer to data or controls get confused.

Try running the query from the immediate window.
For debugging purposes, use actual values instead of variables, until you
hit the variable that doesn't work.


JMorrell said:
Thanks for the reply. I had tried this exact syntax for the dlookup before.
Tried it again and am _still_ getting the #Error message in the control. I
think I've looked just about everywhere for something else that is keeping
this from working. Here's the rundown on my form;

form is based on a query, (SELECT Requests.PubID,
Inventory.NameOfPublication, Requests.Out, Inventory.Available FROM Requests
INNER JOIN Inventory ON Requests.PubID = Inventory.PubID;)
data entry setting = yes.

What am I missing here? Thanks for the help.
JMorrell



Dave M said:
If [boxPubID] is a control on a form, it persumably holds a value like 42,
and what your DLookup really should say is

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = 42")

for that particular instance. To make it general, you need to refer to the
control outside of the string, like this


=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = " & [boxPubID] )


JMorrell said:
If I had more hair I would be pulling it out now.

I'm having a brain freeze on this DLookup. Can someone please tell me why
it fails (#Error)?

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = & [boxPubID] &")

PubID is an autonumber PK in table Inventory and boxPubID is an unbound
control on a form.

many tia,
 
Top