I have a field to input a User ID. It is validated by another table where all the User ID's are stored. The code I have inserted works and makes sure that the user receives a message to describe the problem:
Private Sub UserID_AfterUpdate()
If IsNull(DLookup("UserNum", "tblUsers", "UserNum = '" & [Forms]![frmGenSum]![UserID] & "'")) Then
MsgBox "Please input a valid User ID."
[Forms]![frmGenSum]![UserID] = ""
Else
'Do Nothing
End If
End Sub
The problem I am having is that Microsoft has its own error message after mine: "You cannot add or change a record because a related record is required in table 'tblUsers'." I need to a way to avoid the Microsoft statement altogether. I was trying On Error GoTo and then the If statement, but it still comes up.
What VBA coding can I use to circumvent this? Thanks for the help.