Bob P
Bob P

Reputation: 237

Having Dlookup issues. The code won't work?

Basically it says I am missing operators?

Dim descpc As String

despc = DLookup("[Description]", "[products/stock]", "[Product Code] = " & Me.cmbSource.Value)
Me.Text47.Value = despc

Can anyone spot anything? I'm not 100% with Dlookup so any help would be brilliant!

Thanks, Bob P

Upvotes: 0

Views: 167

Answers (1)

KFleschner
KFleschner

Reputation: 499

You're dim-ing cmbSource as a string, so you'll need to enclose the value in sigle quotes to handle the string. Also, if Product Code is a number, you might get an error if you're then trying to compare a string to an integer. Try this:

despc = DLookup("[Description]", "[products/stock]", "[Product Code] = '" & Me.cmbSource & "'")

Upvotes: 1

Related Questions