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

Access 97 Combo Boxes

Status
Not open for further replies.

meg450

Technical User
Apr 28, 2000
6
US
I have a 3 combo boxes called Division, Department, and SubDepartment. All 3 combo boxes are synchronized. When I select a value from the Division combo box it shows me the correct departments in the Department combo box and when I select a value from the Department combo box is shows me the correct subdepartments in the subdepartment combo box. Now I want it to automatically fill in the Room, Building and Phone that goes with the subdepartment value that I choose. I would appreciate any help. Thanks.
 
So... you wish to default the value of each child combo-box to the first valid value within their respective list. I would imagine, you could use the OnChange Event for each parent combo-box to requery the appropriate children comob-boxes, then simply set the value to the first index item of said child combo-box. This is off the top of my head... but, I recall doing something like that before myself. htwh Steve Medvid
"IT Consultant & Web Master"
 
Steve,
I believe meg already has the Parent/Child combo box issue solved, it's the population of the three text boxes that meg would like assistance with.

Use the OnChange even of the last combo box (subdepartment I believe) and put in some code that looks like this (If you need help on where the code goes, etc. ask and ye shall receive)

Sub COMBONAME_Change()
txtPhoneNum = Dlookup("[PhoneNum]","[TABLENAME]","[SubDeptName] = '" & ComboName & "'")
txtRoom = Dlookup("[Room]","[TABLENAME]","[SubDeptName] = '" & ComboName & "'")
txtBuilding = Dlookup("[Building]","[TABLENAME]","[SubDeptName] = '" & ComboName & "'")
Exit Sub

This will update txtPhoneNum, txtRoom, and txtBuilding (change the name accordingly) to their respective value from TABLENAME (again, change this name to match your table's name) where the SubDepartmentName = the Subdepartment name. this will need to be adjusted depending on how your DB is set up, but hopefully you get the jist. If you nedd any more help, please let me know. Kyle ::)
 
Thanks KyleS for your help. I haven't been able to work on my database yet but I think what you suggested will work. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top