Error after blocking Dupe Record

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Hello there! Using A02 on XP and have a data entry only
form and PlanNum and CheckNum are both primary keys to
avoid duplicate entries. The message appears and you click
okay. The 'bad' data is still there and if I retype 'good'
data(even if I press Escape to clear it), I still get the
duplicate message a second time on the 'good' record. If I
press the AddNew button again it will add it and gotonew.
I've tried If Dirty but must be doing it wrong. Even if I
null all the fields, it still thinks I have the 'bad'
data. I have to close the form and reopen. Am I checking
for duplicate records in the wrong place? It's confusing
for the clerks to know when to press the AddNew button
once or twice. Any help or advice would be appreciated!
Here is what I have...

Private Sub Command79_Click()
On Error GoTo Err_Command79_Click
DoCmd.RunCommand acCmdRecordsGoToNew
Exit_Command79_Click:
Exit Sub
Err_Command79_Click:
Select Case Err.Number
Case 3022
MsgBox "A record containing the Plan Number and
Check Number you have keyed in already exist."
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_Command79_Click
End Select
End Sub

When I use: DoCmd.GoToRecord , , acNewRec all I get is
the "Cannot go to specified record" as often as I click
the button, but if I use DoCmd.RunCommand
acCmdRecordsGoToNew I do get the Duplicate Msgbox as
described above.

Thanks in advance for any help or advice!
 
You may be getting 2 errors, the one you're handling and a "data error"
which would be handled in the Form's OnError event. Try placing a message
box in this event as a test.

Example:
MsgBox "Error Number: " & DataErr
 
Back
Top