S
scott
I'm trying to prevent a user from leaving or tabbing past a combo box
control without selecting a value. If they don't select a value, they get
the referential integrity error below. My AfterUpdate code below won't catch
the error. I'd like to display a warning and then force focus back to the
control when this happens and suppress Access's error warning.
Any help?
ERROR: *****
You cannot add or change a record because a related record is required in
table 'myTable'
CODE: ******
Private Sub cboMyCombo_AfterUpdate()
If Me.Dirty Then
If Not IsNumeric(Me.cboMyCombo) Or IsNothing(Me.cboMyCombo) Then
MsgBox "You must select a record", vbCritical,
CurrentDb().Properties("AppTitle")
Me.cboMyCombo.SetFocus
Exit Sub
End If
End If
End Sub
control without selecting a value. If they don't select a value, they get
the referential integrity error below. My AfterUpdate code below won't catch
the error. I'd like to display a warning and then force focus back to the
control when this happens and suppress Access's error warning.
Any help?
ERROR: *****
You cannot add or change a record because a related record is required in
table 'myTable'
CODE: ******
Private Sub cboMyCombo_AfterUpdate()
If Me.Dirty Then
If Not IsNumeric(Me.cboMyCombo) Or IsNothing(Me.cboMyCombo) Then
MsgBox "You must select a record", vbCritical,
CurrentDb().Properties("AppTitle")
Me.cboMyCombo.SetFocus
Exit Sub
End If
End If
End Sub