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!

Certain Selections within COMBO'S!!!!

Status
Not open for further replies.

Cricker

Technical User
Sep 11, 2002
31
0
0
CA
I am looking for some help with regarding Combo Boxes. I have 3 Combo's (Main Issues - Issues - SubIssues).

When a user selects something in the Main Issues it all depends on what he/she selects that will be able for the Issues and so on with the Sub Issues. I don't want the user to c all selections, only what is available on what he selects.

EXAMPLE:

Community
Schools
Beaconsfield
Brother Rice
Churches
St. Matthew's
St. John's
Services
Ambulances
Red
White
Police
Robbery
Accident
Bylaws
Noise
Loud
Really Loud
Parking
Over Night
Snow

This what the selections would be for example..

Thanks in Advance

cw



 
Hi there the first thing that springs to mind is probably not the best way, but it's pretty simple.

You could create 3 hidden combo-boxes in exactly the same place on the form and have an event procedure based on your main combo-box which activates only one of the three hidden boxes when the main combo-box is updated.

For example if there were 3 choices in the main combo-box then each choice selected would generate it's own unique list in the second combo-box.

Is this the sort of thing required?
 
Try this...
1) create a single table (referenced as Table1 herein) with 3 columns: mainissue, issue, subissue - You can also add a primary key if you'd like. Populate with your issues. Your example above would have 11 records to cover all mainissue/issue/subissue combinations.
2) create a unique value query and combo box for the main issues.
2a) mainissue query - one shown column pulls mainissue from Table1
SQL loks like:
SELECT DISTINCT Table1.[mainissue]
FROM Table1;

2b) combobox (mainissue) - this box's rowsource should be the query created in step 2a.

3) create a unique value query and combo box for the issues.

3a) issue query - one shown column pulls issue from Table1 where mainissue = mainissue chosen in combo box from step 2b.
SQL loks like:
SELECT DISTINCT Table1.[issue]
FROM Table1
WHERE (((Table1.[mainissue])=[forms]![main]![mainissue]));

3b) combobox (issue) - this box's rowsouorce should be the query created in step 3a.

4) create a unique value query and combo box for the sub-issues.

4a) subissue query - one shown column pulls issues from Table1 where mainissue = mainissue chosen in combo box from step 2b and issue = issue chose in combo box from step 3b. (SQL loks like
SELECT DISTINCT Table1.[subissue]
FROM Table1
WHERE (((Table1.[mainissue])=[forms]![main]![mainissue]) AND ((Table1.[issue])=[forms]![main]![issue]));

4b) combobox (subissue) - this box's rowsource should be the query created in step 4a.

5) The final step is to create after update methods for the combo boxes for mainissue and issue. The code is:

Private Sub mainissue_AfterUpdate()
Me.issue.Requery
End Sub

Private Sub Issue_AfterUpdate()
Me.subissue.Requery
End Sub

Sorry for the long winded response. This is actually much easier than it looks.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top