Getting Values from a Combo Box

Adam McReynolds

Registered User.
Local time
Today, 02:50
Joined
Aug 6, 2012
Messages
129
I have created a form with unbound text boxes and the user can apply prices based on DLookup of a table with prices in it. Here is the code that does that:
Code:
Case "Line Extender"
strCriteria = "repair_item = 'Line Extender  Repair' AND profile_types = 'Alpha'" 
.txt_rate1 = DLookup("[flat_rate_values]", "tbl_module_repairs_client_item_details", strCriteria)

That works fine for standard situations. However, the issue is that the name of the Equipment such as "Line Extender" can apply the base price, but if there is a "plus major parts" then a new price needs to be entered and that data will not be in the title; only "Line Extender". So we have a table that lists these prices and I want to be able to add a combo box that pulls from these selections.

The combo box needs to narrow down the search first by querying by customer, which is [profile_types] in the table. On my form I have an unbound text box called [txt_customer1] which will hold the customer name. So I need the combo box to first take the name from this text box and narrow the query down based on this. Then I need the combo box to show the list of [repair_items] based on this customer.

Once a [repair_item] is selected from the list I need it to apply the rate which is [flat_rate_values] in the table; this needs to be applied to my unbound text box [txt_rate1].

Any help would be awesome!

Note: I have 10 rows of these unbound text boxes on my form so that is why I am not using bound text boxes.
 
Ok, solved my own problem. I will show what I did for people who may find this in the future.

First I added code to the row source of my combo box under profile types in the query builder:
Code:
[Forms]![FRM_RF_OUTBOUND_PRICING].[txt_customer1]

Then I added code to the After Update event of that combo box:
Code:
Me.txt_rate1 = DLookup("[flat_rate_values]", "tbl_module_repairs_client_item_details", "repair_item = '" & Me.cmb_client_item1 & "'")

After that I noticed that my [txt_customer1] field needed to refresh so I added the Me.Refresh code to the after update event.

So now I have my base prices set and if I need something adjustable like "major parts" I can select from my combo box and the price is entered.
 

Users who are viewing this thread

Back
Top Bottom