Query based on combo box values

G

Guest

I have 3 combo boxes on a form that users pick numeric values for. Based on
those 3 values, when a user clicks a button, I want to run a query or lookup
a dollar amount from another table for that combination of values. So for
example, I have combo box 1,2,and 3, and text box 1. If combo box 1 has a
value of 1, combo box 2 has a value of 1, combo box 3 has a value of 1, then
it looks up a dollar amount in another table for those values and places the
amount in text box 1 (i.e. $525--stored as numeric (525)). If combo box 1
has a value of 1, combo box 2 has a 1, and combo box 3 has a 2, it may return
$600). Any help would be greatly appreciated. Thanks
 
G

Graham Mandeno

Hi Bill

Use the values in the combo boxes to construct a WHERE clause, then use
DLookup. In your button's Click event procedure:

Dim sWhere as string
sWhere = "[Field1]=" & Combo1 & " and [Field2]=" & Combo2 _
& " and [Field3]=" & Combo3
Text1 = DLookup( "[PriceField]", "YourTable", sWhere )
 

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

Top