Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to follow the instructions to base one combo box on another in an MS Access 2010 form, and I'm running into some issues.

I've got two tables:

Strategy +----+-------------+
         | ID | Desc        |
         +----+-------------+
         | 1  | Annhilation |
         | 2  | Exhaustion  |
         +----+-------------+

Theme    +----+-------------------------+------------+
         | ID | Desc                    | StrategyID |
         +----+-------------------------+------------+
         | 1  | Beauty of Simplicity    | 1          |
         | 2  | Capitalism              | 1          |
         | 3  | Change of power         | 1          |
         | 4  | Change versus tradition | 1          |
         | 5  | Chaos and order         | 2          |
         +----+-------------------------+------------+

I'm trying to make a form with two combo boxes, one for Strategy, one for Theme. I'd like the options for the Theme combo box to be limited by the current selection in the Strategy combo box, that is, only show ones where the StrategyID matches the selected Strategy's ID.

I created a blank form named StrategyTheme and added two combo boxes to it.

Strategy
  Row Source    : SELECT [Strategy].[ID], [Strategy].[Desc] FROM Strategy; 
  On Click      : [Event Procedure]
  Before Update : [Event Procedure]
  After Update  : [Event Procedure]
  On Dirty      : [Event Procedure]
  On Change     : [Event Procedure]
  On Not In List: [Event Procedure]
  On Got Focus  : [Event Procedure]
  On Lost Focus : [Event Procedure]
  On Dbl Click  : [Event Procedure]
  On Mouse Down : [Event Procedure]
  On Mouse Up   : [Event Procedure]
  On Mouse Move : [Event Procedure]
  On Key Down   : [Event Procedure]
  On Key Up     : [Event Procedure]
  On Key Press  : [Event Procedure]
  On Enter      : [Event Procedure]
  On Exit       : [Event Procedure]
  On Undo       : [Event Procedure]
Theme
  Row Source    : SELECT [Theme].[ID], [Theme].[Desc] FROM Theme WHERE [Theme].[StrategyID]=[Forms]![StrategyTheme]![Strategy]; 

The procedures I added should all just refresh the Theme combo box and pop up a message (because I wasn't sure they were being called).

Option Compare Database
Private Sub Sync(msg)
    MsgBox (msg)
    Me.Theme = Null
    Me.Theme.Requery
End Sub
Private Sub Strategy_AfterUpdate()
    Sync ("AfterUpdate")
End Sub
Private Sub Strategy_BeforeUpdate(Cancel As Integer)
    Sync ("BeforeUpdate")
End Sub
Private Sub Strategy_Change()
    Sync ("Change")
End Sub
Private Sub Strategy_Click()
    Sync ("Click")
End Sub
Private Sub Strategy_DblClick(Cancel As Integer)
    Sync ("DblClick")
End Sub
Private Sub Strategy_Dirty(Cancel As Integer)
    Sync ("Dirty")
End Sub
Private Sub Strategy_Enter()
    Sync ("Enter")
End Sub
Private Sub Strategy_Exit(Cancel As Integer)
    Sync ("Exit")
End Sub
Private Sub Strategy_GotFocus()
    Sync ("GotFocus")
End Sub
Private Sub Strategy_KeyDown(KeyCode As Integer, Shift As Integer)
    Sync ("KeyDown")
End Sub
Private Sub Strategy_KeyPress(KeyAscii As Integer)
    Sync ("KeyPress")
End Sub
Private Sub Strategy_KeyUp(KeyCode As Integer, Shift As Integer)
    Sync ("KeyUp")
End Sub
Private Sub Strategy_LostFocus()
    Sync ("LostFocus")
End Sub
Private Sub Strategy_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Sync ("MouseDown")
End Sub
Private Sub Strategy_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Sync ("MouseMove")
End Sub
Private Sub Strategy_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Sync ("MouseUp")
End Sub
Private Sub Strategy_NotInList(NewData As String, Response As Integer)
    Sync ("NotInList")
End Sub
Private Sub Strategy_Undo(Cancel As Integer)
    Sync ("Undo")
End Sub

When I view the form in Form View, the Theme combo box is constrained to match whatever the value of the Strategy combo box was last time I viewed it, and doesn't change when I change what's selected in the Strategy combo box. I don't see any popups from the MsgBox() calls, so I don't think my event callbacks are being called.

What am I doing wrong, and how can I fix it?

share|improve this question
add comment

1 Answer 1

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.