Originally Posted by
GAccess
SSanfu,
Do you think you can tell me how to make use of the onfocus for my third combo?
Very impressive attachment by the way.. however it looks like you coded everything
I use the onFocus event to have the dropdown list visible without having to click in the arrow.
You should use the After update event to do the re-querying and clearing.
In my example, my lookup tables are seperate, where you have one table. Not wrong or bad, just different, so setting up the combo boxes is a little different.
I don't like changing the rowsources. So instead of setting the rowsources in code, I set it when designing the form/combo box.
I would set up the combo boxes like this:
row source
Combo1: "SELECT DISTINCT location FROM tablename"
Combo2: "SELECT DISTINCT Transportation FROMtablename WHERE location = '" & Me.Combo1 & "'"
Combo3: "SELECT DISTINCT color FROMtablename WHERElocation = '" & Me.Combo1 & "' AND transportation = '" & Me.Combo2 & "'"
Then in the after update event of combo box 1, you have to clear the values in combo boxes 2 & 3 and re-query them:
Code:
Private Sub Combo1_AfterUpdate()
Me.Combo2 = NULL
Me.Combo3 = NULL
Me.Combo2.Requery
Me.Combo3.Requery
Me.Combo2.SetFocus
End Sub
' this causes the list to automatically drop down
Private Combo1_GotFocus()
Me.Combo1.Dropdown
End Sub
In combo box 2, you would have:
Then in the after update event of combo box 1, you have to clear the values in combo boxes 2 & 3 and re-query them:
Code:
Private Sub Combo2_AfterUpdate()
Me.Combo3 = NULL
Me.Combo3.Requery
Me.Combo3.SetFocus
End Sub
' this causes the list to automatically drop down
Private Combo2_GotFocus()
Me.Combo2.Dropdown
End Sub
For combo 3:
Code:
' this causes the list to automatically drop down
Private Combo3_GotFocus()
Me.Combo3.Dropdown
End Sub