Populate textbox based on 2 list box selections

mactheknife

Registered User.
Local time
Today, 07:52
Joined
Jan 6, 2014
Messages
12
Hullo there Guru's.

Had a quick look for this as I thought it'd be quite a common problem but can't seem to find a soloution.

I have 2 tables.

tblOrderType
1 - Maintenance Order
2 - Breakdown Order
3 - Greasing Order

tblArea
1 - AreaX - MaintenanceOrderNoX - BreakdownOrderNoX - GreasingOrdernoX
2 - AreaY - MaintenanceOrderNoY - BreakdownOrderNoY - GreasingOrdernoY
3 - AreaZ - MaintenanceOrderNoZ - BreakdownOrderNoZ - GreasingOrdernoZ

On my form I have two list boxes: An Order Type List box, and an Area Listbox.

What query criteria or VBA code would I use so that I could populate a text box with the relevant order number based on the selections of the list boxes. i.e. MaintenanceOrder & Area Z would display MaintenanceOrderNoZ

Any help would be much appreciated as I have no idea the best way forward.
 
The easiest way to do this is to add the fields as hidden fields to your combobox.
Then use the after update event to write the individual information to individual textboxes, remember that a combobox is zero based, meaning the first column isnt numbered 1, but 0.

Alternatively you may consider using a subform to display the data for you.
 
Do you mean have 3 hidden text boxes with all 3 seperate order no's displayed depending upon what Area is selected. And then something like IF listbox.OrderType = 1 THEN Make Textbox.1 Visible?

The problem with that being I then want to store that order number along with the entered report. I know this is bad practice, but it is a temporary soloution until we introduce custom numbers for each individual report as opposed to the same one for a particular area.

I feel this might be getting a bit confusing, would it be easier to understand if I upload my db?
 

Users who are viewing this thread

Back
Top Bottom