Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 16th, 2006, 04:45 AM
Useless Useless is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 9 Useless User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 45 m 21 sec
Reputation Power: 0
Cascading Multiple Combo Boxes and display filtered results in a subform

Hi all,
I have another question about my program regarding combo boxes and subforms. I have 4 combo boxes that presently feed off each other in a specific order, so after cbo1 is selected it populates cbo2 with only those records that have the selected cbo1 entry and it then also filters the datasheet subform, then cbo2 populates cbo3 with those records associated with cbo1 and cbo2 and again filters the subform, then the same for cbo4.
It works fine and I am really happy with how I have got it working (see example below) but what I would like to achieve is to allow the user to select any combo box in any order and reselect them as required with the list being filtered each time and the other combo boxes being populated to reflect the changes.

Here is what I have at present in the AfterUpdate event of the first combo box

'Populate the Second Combo Box
strSQL = "SELECT DISTINCT table.Item2 FROM table "
strSQL = strSQL & " WHERE table.item1 = '" & cboitem1 & "'"
strSQL = strSQL & " ORDER BY table.Item2;"

cboItem2.RowSource = strSQL

'Populate the subform with all data for the selection
strSQLSF = "SELECT * FROM table "
strSQLSF = strSQLSF & " WHERE table.item1 = '" & cboItem1 & "'"


Me!SelectItemSubForm.LinkChildFields = "Item1"
Me!SelectItemSubForm.LinkMasterFields = "Item1"
Me.RecordSource = strSQLSF
Me.Requery



and here is the AfterUpdate event of the third combo box

'Populate the sample date combo box
strSQL = " SELECT DISTINCT table.Item4 FROM table "
strSQL = strSQL & " WHERE table.Item1 = '" & cboItem1 & "' And "
strSQL = strSQL & " table.Item2 = '" & cboItem2 & "' And "
strSQL = strSQL & " table.Item3 = '" & cboItem3 & "'"
strSQL = strSQL & " ORDER BY table.Item4;"

cboItem4.RowSource = strSQL

'Populate the subform
strSQLSF = " SELECT * FROM table "
strSQLSF = strSQLSF & " WHERE table.Item1 = '" & cboItem1 & "' And "
strSQLSF = strSQLSF & " table.Item2 = '" & cboItem2 & "' And "
strSQLSF = strSQLSF & " table.Item3 = '" & cboItem3 & "'"

'Reset the relationship links
Me!SelectItemSubForm.LinkChildFields = ""
Me!SelectItemSubForm.LinkMasterFields = ""

Me!SelectItemSubForm.LinkChildFields = "Item1;Item2;Item3"
Me!SelectItemSubForm.LinkMasterFields = "Item1;Item2;Item3"
Me.RecordSource = strSQLSF
Me.Requery


What I was thinking was to have a generic function set up for each of the 4 events and pass in the information to the functions but I cant quite think how to do it...

Any ideas/suggestions on how to achieve what I am after?

Cheers.

Reply With Quote
  #2  
Old June 23rd, 2006, 04:01 AM
Useless Useless is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 9 Useless User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 45 m 21 sec
Reputation Power: 0
Sorted.
I wrote code to cover all situations and used an IF to check which combos were selected. There was probably an OO method of doing it but im too long out of the game to be trying it

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Cascading Multiple Combo Boxes and display filtered results in a subform


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT