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

HELP- combo box problem

Status
Not open for further replies.

vz

MIS
Jul 31, 2001
131
US
O.k. i have 2 tables table one has account num and employee in table 2 has employee in it only. i want to connect the account num field on my form to the 1st table using an ado datacontrol, then i want to be able to connect employee from table one to same datacontrol, but i want it to be a drop down box and i want the options to be pulled from the second table which is essentially a list for my drop down box and nothing more. how can i store the field and pull itfrom the main table but use the other table for its drop down options?
 
I am a little unclear what you are looking for. Do you want one drop down box (ddb1) that just has a list of employee numbers, and then another one (ddb2) that has a list of the accounts only for the employee selected in ddb1? I may be making this more complex than what you are actually looking for, so please bear with me if this is the case.
 
No I just want one combo box that will store the information IN table1 but the dropdown list for that box needs to come FROM table2. I am using 2 bound ado controls. does that make sense? I hope I explained it better. Thanks for your help.
 
Yep, I get it now. Whatever value is in there will get stored into table 1, but you want the drop down list they can select from to be loaded with all the values from table 2, right? I have to say, I'm not sure how to do that with bound controls since I try to stay away from using bound controls (I like to have more control over my database operations, plus there are performance issues to consider with that). I "think" (let me stress "think" here) that you can do this with two ado controls, each linked to the same database but different tables (table 1 and 2). When you load the form you can cycle through the table 2 ado control using the combo box's AddItem method to add the EmployeeNumber for each record in table two. The combo box itself is bound to the ado control for table 1, though. Does that make sense? Basically, you do a MoveFirst on ado control 2 (for table 2) and loop doing a MoveNext until you are at EOF (or whatever the end of the records is known by in the ado control). For each of those records you say ComboBox.AddItem(EmployeeNumber) and off you go. You bind the combo box itself the same way as usual. Here's the caveat, I don't know if the list box is already pre-populated with the distinct values for the field it is bound to, so you may have to remove those first and then rebuild the list to ensure you don't have duplicates in the drop down.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top