I have a form that has 2 combo boxes that I need to make sure an item is selected in before the record is upated. I have the following code in the BeforeUpdate event. The first "if" statement works, the message box pops up, then the focus is set to that control and I select an item. The next time i try to activate the BeforeUpdate event to test the second box i get the error:
"The Microsoft Jet database engine cannot find a record in the table 'tblBoro' with the key matching field(s) 'loc_boro'"
The second combo box that is being validated contains the items listed in tblBoro - a boro id (autonumber) and the boro (manhattan, bronx, etc). The table is linked to the main table, tblLocation, that has a numeric field, loc_boro.
Thanks for your help.
Mike
"The Microsoft Jet database engine cannot find a record in the table 'tblBoro' with the key matching field(s) 'loc_boro'"
The second combo box that is being validated contains the items listed in tblBoro - a boro id (autonumber) and the boro (manhattan, bronx, etc). The table is linked to the main table, tblLocation, that has a numeric field, loc_boro.
Code:
Private sub form_BeforeUpdate(cancel as integer)
on error goto err_before
if Me.cmbCommunity = "" or IsNull(Me.cmbCommunity) Then
MsgBox "You must select a community."
GoTo Exit_Before
ElseIf Me.cmbBoro = "" or IsNull(Me.cmbBoro) Then
MsgBox "You must selet a county"
GoTo Exit_Before
End If
Exit_Before:
Exit Sub
Err_Before:
MsgBox Err.Description
Resume Exit_Before
End Sub
Thanks for your help.
Mike