Dlookup after Combo

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

Guest

I keep getting a run time error 2001 (or #Error etc)after choosing a
ProductID from the combo i have tried OnExit,LostFocus and putting the
Dlookup in the control source and setfocus if someone could point me in the
right direction for me to try and figure out myself.
Thanks

txtInvoiceDescription.SetFocus
txtInvoiceDescription = DLookup("[InvoiceDescription]", "tblProducts",
"ProductID = " & Forms!fsubInvoiceDetail!cmbProductID)
 
Hi Michael G,

If ProductID is a number then,
txtInvoiceDescription = DLookup("[InvoiceDescription]", "tblProducts",
"ProductID = " & Me.cmbProductID & "")
whereas if it's a text field or contains any letters at all;
txtInvoiceDescription = DLookup("[InvoiceDescription]", "tblProducts",
"ProductID = '" & Me.cmbProductID & "'")
Best put in the After_update event of the combobox.

hope this helps,

tonyT..
 
TonyT

Works fine
Thanks for your help.

Michael G

TonyT said:
Hi Michael G,

If ProductID is a number then,
txtInvoiceDescription = DLookup("[InvoiceDescription]", "tblProducts",
"ProductID = " & Me.cmbProductID & "")
whereas if it's a text field or contains any letters at all;
txtInvoiceDescription = DLookup("[InvoiceDescription]", "tblProducts",
"ProductID = '" & Me.cmbProductID & "'")
Best put in the After_update event of the combobox.

hope this helps,

tonyT..



michael G said:
I keep getting a run time error 2001 (or #Error etc)after choosing a
ProductID from the combo i have tried OnExit,LostFocus and putting the
Dlookup in the control source and setfocus if someone could point me in the
right direction for me to try and figure out myself.
Thanks

txtInvoiceDescription.SetFocus
txtInvoiceDescription = DLookup("[InvoiceDescription]", "tblProducts",
"ProductID = " & Forms!fsubInvoiceDetail!cmbProductID)
 

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

Back
Top