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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with combo boxes please

Status
Not open for further replies.

Visiting

IS-IT--Management
Nov 26, 2002
21
0
0
US
Hi. I have two combo boxes that have corresponding field values. Let's say my first combo box is "NAME" and the second combo box is PHONE NUMBER. If i select a name from the first combo box, how can I update the value in the phone number field of the second combo bux. Basically, I want to update all fields whenever a corresponding value is selected. So if I select a person's name, the correct phone number will be displayed in the second combo box. I want this to be able to work in reverse as well, so if i select a phone number from the 2nd combo box, the person's name will show up in the 1st combo box. Thanks again for your help
 
To keep your cbo updated. Use the event property of the cbo. User the onchange of the cbo. Write the code for the onchange to requery the other cbo.

Here is the code for the onchange of the phoneNumber cbo
me.cboName.requery

Here is the code for the onchange of the Name cbo
me.cboPhoneNumber.requery

Brodi
 
Are you sure you want 2 combo boxes? Sounds like the user can select any person from the list in the combo box, but the result sound like you just want to display that person's phone number. There's no need for the 2nd box to be a combo...a text box should be sufficient.

In this scenario, on the AFTER UPDATE property of the first combo box use something like this EVENT PROCEDURE

Me![PHONE FIELD].SetFocus
Me![PHONE FIELD] = DLookup("[PHONE]", "[SOURCE OF FORM]", "[NAME] = [COMBOBOX]")

Hope this helps.

Jim "Get it right the first time, that's the main thing..." [wavey]
 
I forgot to mention. The requery will only work if the two cbo are tied together. If they are not tied together, you will have to search the records based upon the value of the cbo you have choose. You would write the vba code for each one in the onchange event.

Brodi
 
Thanks to both of you guys. Brodi, how would i tie the two combo boxes together?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top