DLookUp error

C

cmraguilar

I'm having issues with a DLookUp function. Its set up, or so I think, to
pull a company name from a combo box and then display their WSI number. The
combo box also executes 2 quries in seperate subforms On Change and On Got
Focus. When the DLookUp is set as below, I get a #Error. But when I set the
combo box set the "Bound Comlumns" = 2, the text box will display the number
but will I get a Run-time error '3420' Object invalid or no longer set.

Any help would be appreciated.

=DLookUp("[ParentWSINumber]","tblSupplierParent","[SupplierName]='" &
Nz(Forms![Supplier Contact Information]!cboSupplierParentName) & "'")
 
J

Jim B

The bound column from the Lookup box is usually the ID Number from whatever
recordset is used for the combo box. The second column displays the data -
in this case, the SupplierName. In your Dlookup function, you are looking
for a text value of SupplierName, but the boundcolumn of the box is probably
a number. Try using the column property of the combo box.

=DLookUp("[ParentWSINumber]","tblSupplierParent","[SupplierName]='" &
Nz(Forms![Supplier Contact Information]!cboSupplierParentName.Column(2)) &
"'")

This will let you reference the text value, rather that the numeric value.
 
C

cmraguilar

Thanks for your help. I appreaciate the detailed explination rather than
just respoding with the code. It helps me understand the why, rather than
the how. The only change I needed to make was reference it to column(1)
rather than column(2).

Jim B said:
The bound column from the Lookup box is usually the ID Number from whatever
recordset is used for the combo box. The second column displays the data -
in this case, the SupplierName. In your Dlookup function, you are looking
for a text value of SupplierName, but the boundcolumn of the box is probably
a number. Try using the column property of the combo box.

=DLookUp("[ParentWSINumber]","tblSupplierParent","[SupplierName]='" &
Nz(Forms![Supplier Contact Information]!cboSupplierParentName.Column(2)) &
"'")

This will let you reference the text value, rather that the numeric value.

cmraguilar said:
I'm having issues with a DLookUp function. Its set up, or so I think, to
pull a company name from a combo box and then display their WSI number. The
combo box also executes 2 quries in seperate subforms On Change and On Got
Focus. When the DLookUp is set as below, I get a #Error. But when I set the
combo box set the "Bound Comlumns" = 2, the text box will display the number
but will I get a Run-time error '3420' Object invalid or no longer set.

Any help would be appreciated.

=DLookUp("[ParentWSINumber]","tblSupplierParent","[SupplierName]='" &
Nz(Forms![Supplier Contact Information]!cboSupplierParentName) & "'")
 

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 is broken... 1
Trouble with DLookup 3
DLookup Function 2
Dlookup issue with Access 2003! PLEASE HELP!!! 1
DLOOKUP 2
DLookUp #Error 7
Default value of combo box based on DLookUp 2
Add to text box String 4

Top