Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trap the 3022 error 1

Status
Not open for further replies.

annie52

Technical User
Mar 13, 2009
164
US
I can't figure out how to trap the 3022 error that's generated when I enter a duplicate record and then try to leave the record via the navigation buttons. None of the form's events seem to catch this error.
 
How have you tried? Are you trying to capture the code in VBA with an error-handler routine?

--

"If to err is human, then I must be some kind of human!" -Me
 
Hi, kjv1611. I'm not sure I know what you mean by "an error-handler routine". Here's what I have in the form's OnError event:

On Error GoTo Err_Form_Error

Exit_Form_Error:
Exit Sub

Err_Form_Error:
If Err.Number = 3022 Then
MsgBox "That requisition number already exists."
Response = acDataErrContinue
Else
MsgBox "Error #" & Err.Number & " " & Err.Description
End If
Resume Exit_Form_Error

It doesn't trap this error though.
 

Code:
Private Sub Form_Error(DataErr As Integer, Response As 
Integer)
Dim Message As String
If DataErr = 3022 Then 'Duplicate value entered
 Message = "That requisition number already exists."
 Response = MsgBox(Message, vbExclamation, "Registration Number Exists!")
 Response = acDataErrContinue
End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Hi, missinglinq. That's exactly what I needed. Thank you so much. I never had any formal training with Access or VBA and never learned about DataErr until just now. You're the best!
 
Glad to help! I'm also self taught! Just takes some reading, looking at others apps/code and a whole lot of work! I've been writing code for almost twenty years now, Access/VBA for oevr a decade and I learn something every day!

Good Luck!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top