Hey! Thanks for taking time to read my post!
I am having a problem on figuring out where to place the error handeling code for a 3201 error (You cannot add or change a record because a related record is required in table '|') and 3022 error (duplicate primary key error) that I am getting. I understand what the error is for and why I am getting it, but I am not sure where to put the code to display a custom message.
The error happens when a user, who accidentally entered an invalid value, tries to change focus from the subform to the main form with the invalid value still present on the subform. I have an error handeling set up on the 'After update' for the particular field itself, which works great:
Const errorcode1 As Integer = 3201
Const errorcode2 As Integer = 3022
On Error GoTo Skip1
DoCmd.Requery
Skip1: If ERR = errorcode1 Then
MsgBox "You have entered to many numbers into the Request ID field, Or this Request number does not exist."
Exit Sub
End If
If ERR = errorcode2 Then
MsgBox "The Request you are trying to enter has already been ordered. Please enter a new Request ID into the field."
Exit Sub
End If
However when the user changes focus from the sub form to the main form, again with the invalid value still present, I still get the 3201 and 3022 error (I have tried putting it in the change focus events but it does not seem to work, unless I am putting it in wrong. I have no other code in those events if that makes a difference). I cant figure out where to place the error handeling for this event.
Thanks for the help and I hope that you have a good day! If you are confused, let me know and I will try to explain it better.
Starlancer