In Access 2010, I am struggling with making a combobox force users to give it input on a data entry form. In this case, I want the combobox to detect that the user has made no selection at all.
I've put the included code in the OnClick, BeforeUpdate, and OnChange events of cbo_Event1. cmb_StartOfSeason, cmb_EndOfSeason, and cmb_MoneyRequired are comboboxes which will provide details for the user about cbo_Event1 on the search form. All four comboboxes are linked to other tables for lookup values.
I've made bound (cbo_Event1) and unbound (cmb_Event) versions of the combobox. I've also used Me.cbo_Event1.Value, Me.cbo_Event1.ListIndex, and Me.cbo_Event1 in the code.
Private Sub cbo_Event1_AfterUpdate()
MsgBox ("Me.cbo_Event1 = " & Me.cbo_Event1 & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
Private Sub cbo_Event1_Change()
MsgBox ("Me.cbo_Event1 = " & Me.cbo_Event1 & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
Private Sub cbo_Event1_Click()
MsgBox ("Me.cbo_Event1 = " & Me.cbo_Event1 & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
Private Sub cmb_Event_AfterUpdate()
MsgBox ("Me.cmb_Event = " & Me.cmb_Event & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
Private Sub cmb_Event_BeforeUpdate(Cancel As Integer)
MsgBox ("Me.cmb_Event = " & Me.cmb_Event & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
Private Sub cmb_Event_Change()
MsgBox ("Me.cmb_Event = " & Me.cmb_Event & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
Private Sub cmb_Event_Click()
MsgBox ("Me.cmb_Event = " & Me.cmb_Event & ".")
If Me.cmb_Event = 0 Then
Me.cmb_StartOfSeason = 0
Me.cmb_EndOfSeason = 0
Me.cmb_MoneyRequired = 0
End If
End Sub
I get the same result across the board: the Event combobox does not detect that no selection was made when its drop-down list appears. The MsgBox function doesn't even trigger, indicating the event doesn't take place. I'm baffled as to why.
