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!

combobox population based on another combobox 1

Status
Not open for further replies.

zgtrman

Programmer
Dec 4, 2002
62
US
I am having trouble with finding out how I can populate a combobox based on a selection of another combo box, all controls are on the same form. combobox1(named OS) is unbound and gets its list from a table (OS)
combobox2(Procedure) would be populated with a field from the selected OS table..all the OS tables have the same fields in them but they are all different tables
1 WIN95
2.WIN98
3.WINME
4.WIN2K
5.WINXP
Then when I select the correct procedure a text box would then be populated from another field (notes) from the table
I know how to do this in VB6 but VBA is rather new to me especially in ACCESS. reason I just do not do this in VB is because I am restricted to the tools that are on my workstation at my job.
Any help in this matter is greatly appreciated
Thank You
 
If I understand this correctly the combobox OS is to have the Operating System field displayed for selection. Because the table OS has more than one record for each Operating System we must use a query to get it down to just a single instance of the Operating System. So we use some SQL to create a list of Operating Systems.

Code:
Select OS.[Operating_System] FROM OS GROUP BY OS.[Operating_System] ORDER BY OS.[Operating_System];

The OS combo should have its Bound Column set to 1 and width set to 1. The AfterUpdate event procedure should have the following VBA code:

Code:
Me![Procedure].Requery

The RowSource property of the Procedure ComboBox should be set to the following SQL:

Code:
Select OS.[Procedure], OS.[Notes] FROM OS WHERE OS.[Operating_System] = FORMS![yourformname]![OS] ORDER BY OS.[Procedure];

Now the Procedure combobox should have the Column Count = 2, Bound Column = 1 and the width set to 2,0" . The Procedure will be visible but the Notes will not as the width is 0 for the notes column.

Put the following VBA code in the AfterUpdate event procedure of the Procedure Combobox:

Code:
Me![Notes] = Me![Procedure].column(1)

The column property of a combobox are enumerated starting at 0 thus the 1 value for the second column.

Post back if you have any further questions.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
scriverb

Thank you for your response, the OS table is a table onto itself but I can see in your code what to do

Thank You!!!!!
 
I am glad to have helped you. Thanks for the Star as it is appreciated. Post back if you get stuck or need more assistance.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top