Another DLookup question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,
 
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] )
 
Try:

=DLookUp("[NameOfPublication]","[Inventory]","[PubID] = " & [boxPubID])
 
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,
 
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,
 

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

Dlookup 3
DLookup Function 2
Dlookup to compare two values? 0
DLookUp behavior 1
Trouble with DLookup 3
What am I doing wrong: DLookUp 2
DLOOKUP 2
Another DLookup Question 2

Back
Top