Capturing Error Messages

Results 1 to 2 of 2

Thread: Capturing Error Messages

  1. #1
    rrt Guest

    Default Capturing Error Messages

    I&#039;m posting data into an Access database through a form. If I post a new record with a value for the primary key field already existing in the database, I get an error after submitting the form. Which is;<BR><BR>Microsoft JET Database Engine error &#039;80004005&#039; <BR><BR>The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.<BR><BR>Is there any way that I could capture this error in my code and display my own message instead of this error message? Any help would be greatly appreciated. Thank You.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Capturing Error Messages

    Put this at the top of your page:<BR>&#060;% On Error Resume Next %&#062;<BR><BR>after your cn.execute(SQL), type this:<BR><BR>If cn.errors.count &#060;&#062; 0 Then<BR> If Err.Number = "80004005" Then<BR> response.write "problem with primary key"<BR> Else<BR> response.write "unknown error"<BR> End If<BR>End If<BR><BR>This should work.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts