Trapping Error 3314

Dreamweaver

Well-known member
Local time
Today, 15:06
Joined
Nov 28, 2005
Messages
2,467
I have been trying to trap this error so I can display a better mesaage or better react to the problem I know why the error is happening and don't wish to redisign the table but would like a cleaner message.


attachment.php




Hope somebody can help thanks


mick
 

Attachments

  • 2019-04-01.png
    2019-04-01.png
    16.5 KB · Views: 643
Hi. If this is on a form, have you tried the form's OnError event?
 
Thanks dbguy managed to sort it after putting my brain back on lol I trapped it on the before update and set cancel = True if the id field was nothing Which seems to stop it displaying the record as I cancelled the update of the form.


Did try the on error without any luck
 
You can handle it in the form's On Error event, but I'd probably prevent it in the before update event.
 
Hi. Glad to hear you got it sorted out. Good luck with your project.
 
Geez, this is what happens when I go test first. :p
 
Did try the on error without any luck

My quick and dirty test which appeared to work in the error event:

Code:
  If DataErr = 3314 Then
    MsgBox "blah"
    Response = 0
  End If
 
Thanks All Brain engaged again lol


Next brain freeze scheduled for next week lol
 
What I don't understand is why is it always the last form of a project to play up lol
 
Let us not forget that table fields with restraints can have custom messages defined at the field level. At least that's my recollection. Just sayin' for anyone who might land here in the future.
 
This is how I handled it in the end but pbaldy Works as well


Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo HandleErr

If IsNothing(Me![ClassID]) Then
    MsgBox "You must select or enter an item in the Category Class", vbInformation + vbOKOnly, "Invalid Entry"
    Me![ClassID].SetFocus
    Cancel = True
 End If
 
HandleExit:
    Exit Sub
    
HandleErr:
    Select Case Err.Number
        Case 2501 'Cancel = True
            Exit Sub
        Case Else
            MsgBox Err.Number & vbCrLf & Err.Description
            Resume HandleExit
        Resume
    End Select
End Sub


IsNothing is a function I found years ago but I use it all the time as saved me more than once google it I think it's still out there
 

Users who are viewing this thread

Back
Top Bottom