form cbo filter

kidrobot

Registered User.
Local time
Today, 01:25
Joined
Apr 16, 2007
Messages
409
I have cascaded 6 of my combo boxes. So the second box is dependent on the first box, the third box is dependent on the first and second... so on and so on. When my form opens up all the boxes are blank. What I want to do is when the user chooses from the first box to show the first item in the second box, and so on. I got this working by using Itemdata(1), but if I pick from the first box and the second box is populate and I want that record so I go to the 3rd box, nothing will be in the 3rd box because my code is AfterUpdate show itemdata 1. So I have to manually go in and click on that choice for the 3rd box to populate value. Any help? Sorry if I couldn't word my problem better.
 
you still have to set up your AfterUpdate procedures for each cbobox so they can be called.

Code:
Private Sub cbo1_AfterUpdate()
    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cbo2.Requery
    
    varID1 = Me.cbo2.ItemData(0)
    Me.cbo2 = varID1
    
    Call cbo2_AfterUpdate
    
    varID2 = Me.cbo3.ItemData(0)
    Me.cbo3 = varID2
    
End Sub
 
I do, I have this for my first two boxes... the remaining boxes also have similar code

Code:
Private Sub cboOrigin_AfterUpdate()
''''''''''''''''''''''''''''''''''''''''FILTER START
Me.cboDestination = Null
Me.cboRoad = Null
Me.cboJunction = Null
Me.cboTC = Null
Me.cboLE = Null
Me.cboDestination.Requery
End Sub

Private Sub cboDestination_AfterUpdate()
Me.cboRoad = Null
Me.cboJunction = Null
Me.cboTC = Null
Me.cboLE = Null
Me.cboRoad.Requery
End Sub

Thanks though, I'll try out what you said!
 
you still have to set up your AfterUpdate procedures for each cbobox so they can be called.

Code:
Private Sub cbo1_AfterUpdate()
    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cbo2.Requery
    
    varID1 = Me.cbo2.ItemData(0)
    Me.cbo2 = varID1
    
    Call cbo2_AfterUpdate
    
    varID2 = Me.cbo3.ItemData(0)
    Me.cbo3 = varID2
    
End Sub

So would I do this code 6 times for each box?
 
Here is my code, not sure if this is the best way to do it...

Code:
Private Sub cboOrigin_AfterUpdate()
    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cboDestination.Requery
    
    varID1 = Me.cboDestination.ItemData(0)
    Me.cboDestination = varID1
    
    Call cboDestination_AfterUpdate
    Call cboRoad_AfterUpdate
    Call cboJunction_AfterUpdate
    Call cboTC_AfterUpdate
    
    varID2 = Me.cboRoad.ItemData(0)
    Me.cboRoad = varID2
    
End Sub

Private Sub cboDestination_AfterUpdate()
    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cboRoad.Requery
    
    varID1 = Me.cboRoad.ItemData(0)
    Me.cboRoad = varID1
    
    Call cboRoad_AfterUpdate
    Call cboJunction_AfterUpdate
    Call cboTC_AfterUpdate
    
    varID2 = Me.cboJunction.ItemData(0)
    Me.cboJunction = varID2
    
End Sub

Private Sub cboRoad_AfterUpdate()
    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cboJunction.Requery
    
    varID1 = Me.cboJunction.ItemData(0)
    Me.cboJunction = varID1
    
    Call cboJunction_AfterUpdate
    Call cboTC_AfterUpdate
    
    varID2 = Me.cboTC.ItemData(0)
    Me.cboTC = varID2
    
End Sub
Private Sub cboJunction_AfterUpdate()
    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cboTC.Requery
    
    varID1 = Me.cboTC.ItemData(0)
    Me.cboTC = varID1
    
    Call cboTC_AfterUpdate
    
    varID2 = Me.cboLE.ItemData(0)
    Me.cboLE = varID2
    
End Sub

Private Sub cboTC_AfterUpdate()

    
    Dim varID1 As Variant
    Dim varID2 As Variant
    
    Me.cboLE.Requery
    
    varID1 = Me.cboLE.ItemData(0)
    Me.cboLE = varID1
    
End Sub
 
any suggestion or criticisms on the way I am doing this?
 
hi. this is a new thing for me and am still experimenting. i think you're on the right track though. i've commented out a few lines that i think you do not need. have a look below. i have to run now and will try to check back later. let us know if this works. w.
Code:
Private Sub cboOrigin_AfterUpdate()
    
    Dim varID1 As Variant
'    Dim varID2 As Variant
    
    Me.cboDestination.Requery
    
    varID1 = Me.cboDestination.ItemData(0)
    Me.cboDestination = varID1
    
    Call cboDestination_AfterUpdate
'    Call cboRoad_AfterUpdate
'    Call cboJunction_AfterUpdate
'    Call cboTC_AfterUpdate
    
'    varID2 = Me.cboRoad.ItemData(0)
'    Me.cboRoad = varID2
    
End Sub

Private Sub cboDestination_AfterUpdate()
    
    Dim varID1 As Variant
'    Dim varID2 As Variant
    
    Me.cboRoad.Requery
    
    varID1 = Me.cboRoad.ItemData(0)
    Me.cboRoad = varID1
    
    Call cboRoad_AfterUpdate
'    Call cboJunction_AfterUpdate
'    Call cboTC_AfterUpdate
    
'    varID2 = Me.cboJunction.ItemData(0)
'    Me.cboJunction = varID2
    
End Sub

Private Sub cboRoad_AfterUpdate()
    
    Dim varID1 As Variant
'    Dim varID2 As Variant
    
    Me.cboJunction.Requery
    
    varID1 = Me.cboJunction.ItemData(0)
    Me.cboJunction = varID1
    
    Call cboJunction_AfterUpdate
'    Call cboTC_AfterUpdate
    
'    varID2 = Me.cboTC.ItemData(0)
'    Me.cboTC = varID2
    
End Sub
Private Sub cboJunction_AfterUpdate()
    
    Dim varID1 As Variant
'    Dim varID2 As Variant
    
    Me.cboTC.Requery
    
    varID1 = Me.cboTC.ItemData(0)
    Me.cboTC = varID1
    
    Call cboTC_AfterUpdate
    
'    varID2 = Me.cboLE.ItemData(0)
'    Me.cboLE = varID2
    
End Sub

Private Sub cboTC_AfterUpdate()
    
    Dim varID1 As Variant
'    Dim varID2 As Variant
    
    Me.cboLE.Requery
    
    varID1 = Me.cboLE.ItemData(0)
    Me.cboLE = varID1
    
End Sub
 
Last edited:
Hi, This post is very informative, however I would like some specific information. If someone can help me then please send me a private message. Best Regards
 
Last edited:

Users who are viewing this thread

Back
Top Bottom