Question : Dynamic combo box rowsource based on prior combo box value

My first combo box, Category, may be Race, Gender, or Age.  

My second combo box, Group, is based on the first.

I have this sub:

Private Sub Form_Current()
Dim Categry As Integer
Categry = Nz(Me!CategoryID.Value, 0)
GroupID.RowSource = "SELECT ReferenceID, ReferenceDesc FROM ReferenceLists WHERE (ReferenceList = " & Categry & ") ORDER BY Seq"
End Sub

When I first open the form, the first record shows up as needed:
 * Category was already defined as Gender.
 * Group was already Female.
 * Everything displays properly.

I press PageDown, and the second record also is displayed properly:
 * Category was already defined as Gender.
 * Group was already Male.

But the third record is not so good:
 * Category, already defined as Race, is displayed properly.
 * Group seems to be blank, but after pressing alt-Tab twice, it shows up as "African American", which is what is needed.

I press PageUp, going back to the second record and:
 * Category, already defined as Gender, is displayed properly.
 * Group seems to be blank, but after pressing alt-Tab twice, it shows up as "Male", which is what is needed.

It must be that I'm not linking my RowSource logic with the appropriate event, but I've been tickling this thing for 4 hours already, and I'm ready for any insight that will give me a clue on how to make this work intuitively.

Thanks!

Answer : Dynamic combo box rowsource based on prior combo box value

add
me.GroupID.requery
after your Row Source code

jaffer
Random Solutions  
 
programming4us programming4us