Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating text control from Combo Box using DLookup 1

Status
Not open for further replies.

DHSBW

Technical User
Jan 23, 2007
11
US
Hi:

Here is the following simple one code I have in the "On Change" event of combo12 combo box:

Private Sub Combo12_Change()
[Forms]![Orders Form]!Text25 = DLookup("[Unit Price]", "Products", "[Product Description]= '" & [Forms]![Orders Form]!Combo12 & "'")
End Sub


I want to use the selected value in Combo12, which gives a list of product descriptions, as the search criteria for looking up the unit price in the "Products" table, and then populating the "text25" text control on the same form with that value, which is a currency datatype. I'm getting a syntax error: Missing operator in query expression.... Thanks for the help in advance.
 
Maybe [Forms]![Orders Form]!Combo12.Text or
[Forms]![Orders Form]!Combo12.Value?

Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes.
 
A safer way:
Code:
[Forms]![Orders Form]!Text25 = DLookup("[Unit Price]", "Products", "[Product Description]='" & Replace([Forms]![Orders Form]!Combo12, "'", "''") & "'")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top