将一个组合框建立在另一个组合框之上

将一个组合框建立在另一个组合框之上

我正在尝试按照说明将一个组合框建立在另一个组合框之上在 MS Access 2010 表单中,我遇到了一些问题。

我有两张桌子:

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          |
         +----+-------------------------+------------+

我正在尝试制作一个包含两个组合框的表单,一个用于策略,一个用于主题。我希望主题组合框的选项受策略组合框中当前选择的限制,即仅显示与所选StrategyID策略匹配的选项ID

我创建了一个名为的空白表单StrategyTheme并在其中添加了两个组合框。

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]; 

我添加的所有程序都应该刷新主题组合框并弹出一条消息(因为我不确定它们是否被调用)。

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

当我在“表单视图”中查看表单时,“主题”组合框被限制为与我上次查看“策略”组合框时的值相匹配,并且当我更改“策略”组合框中选择的内容时,它不会更改。我没有看到来自MsgBox()调用的任何弹出窗口,因此我认为我的事件回调没有被调用。

我做错了什么?我该如何解决?

答案1

相关内容