How to make a textbox that is automatically filled based on two selected combo boxes?

ariansman

Registered User.
Local time
Today, 12:25
Joined
Apr 3, 2012
Messages
157
Combo boxes A and B are looking up texts from a table which has three fields: field 1: Personnel Names (PN), Field 2: Personnel Dimension (PD) such as Height and weight, and field 3: Related Data (RD). So we have a unique triplet combination. For example: (John, weight, 88), or (John, height, 180). I know how to make the comboboxes A and B to select texts based on PN and PD. But could you let me know how to make a textbox to show automatically the unique third data? I hope I could convey my meaning clearly.

Thank you
 
This code will perform a lookup to find the value when either ComboBoxA or ComboBoxB is updated.

You will need to update the table, field and control names that are highlighted in red.

Code:
Sub UpdateTextBox()
    Me![COLOR=Red]TextBox[/COLOR] = Nz(DLookup("[COLOR=Red]PN[/COLOR]", "[COLOR=Red]TableName[/COLOR]", "[COLOR=Red]PN[/COLOR]=" & Me![COLOR=Red]ComboBoxA[/COLOR] & " AND [COLOR=Red]PD[/COLOR]=" & Me![COLOR=Red]ComboBoxB[/COLOR]),vbNullString)
End Sub

[COLOR=Red]ComboBoxA[/COLOR]_AfterUpdate()
    UpdateTextBox
End Sub

[COLOR=Red]ComboBoxB[/COLOR]_AfterUpdate
    UpdateTextBox
End Sub
 
tnx a lot dear sparks80 :)
 

Users who are viewing this thread

Back
Top Bottom