Dlookup after Combo

M

michael G

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

TonyT

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

michael G

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)
 
Top