Welshgasman,
The message about the Image File not being where it is supposed to be is because of the Image Path Field has a path where it expects to find an image file which you don't have on your system, so that error is working correctly.
I changed it so the OnError statement is before any code executes I believe.
Code:
Private Sub MfrPartNumber_AfterUpdate()
On Error GoTo ErrHandler
If Me.Dirty Then 'to check if any data has changed.
DoCmd.RunCommand acCmdSaveRecord
End If
Dim ErrorNumber As Integer
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "The PN Entered is a Duplicate PN and is not allowed, Please enter a different PN"""
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Dave's Database"
'Help = "DEMO.HLP"
'Ctxt = 1000
Response = MsgBox(Msg, Style, Title, , Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
Exit_ErrorHandler:
Exit Sub
ErrHandler:
Dim intErrNum As Integer
intErrNum = Err
If intErrNum = 3022 Then
DoCmd.SetWarnings False
ErrorNumber = Err.Number
'MsgBox "The PN Entered is a Duplicate PN and is not allowed, Please enter a different PN", , "Daves MiniMRP"
MsgBox "The PN Entered is a Duplicate PN and is not allowed, Please enter a different PN" & _
vbCrLf & ErrorNumber, , "Daves MiniMRP"
Me.PartImage.Picture = ""
Me.txtImagePath = ""
Me.MfrPartNumber.SetFocus
End If
End Sub
It still isn't working as I would like though, now it goes back to the PN field but if you hit "Tab" it just goes to the next field rather that forcing the user to change the PN. That is probably because of the Me.Dirty Statement correct?