Problem trapping Error 3200

  • Thread starter botuco via AccessMonster.com
  • Start date
B

botuco via AccessMonster.com

I have a one-to-many relationship from table TbX to TbY with referential
integrity turned on, cascade updates/deletes turned off. I have a form with
a command button to delete records from TbX in it.

As expected, if I try to delete a record from TbX using the command button, I
get an error (Error Number 3200) stating “The record cannot be deleted or
changed because ‘TbY’ includes related records.†I added error handling to
the button to display a custom message. This is what I came up with:

Private Sub cmd_delete_Click()
On Error GoTo Err_cmd_delete_Click

DoCmd.RunCommand acCmdDeleteRecord

Exit_cmd_delete_Click:
Exit Sub

Err_cmd_delete_Click:

Select Case DataErr

Case 3200
MsgBox “you cannot delete this recordâ€
Exit Sub

Case Else
Resume Exit_cmd_delete_Click

End Select
End Sub

Now, when I click the button nothing happens. The record is not deleted but
no message box is displayed.

I have also tried adding the error handling to the forms OnError event but
when I do this, Error 3200 is still displayed. I have searched this and
other forums without finding any answers.

Any suggestions?
 
T

tina

i think you'll want to handle this error in the form's Error event. to
suppress the default error message, just add the following line to the event
procedure, as

Response = acDataErrContinue

hth
 
R

ruralguy via AccessMonster.com

Try: Select Case Err.Number
I have a one-to-many relationship from table TbX to TbY with referential
integrity turned on, cascade updates/deletes turned off. I have a form with
a command button to delete records from TbX in it.

As expected, if I try to delete a record from TbX using the command button, I
get an error (Error Number 3200) stating “The record cannot be deleted or
changed because ‘TbY’ includes related records.†I added error handling to
the button to display a custom message. This is what I came up with:

Private Sub cmd_delete_Click()
On Error GoTo Err_cmd_delete_Click

DoCmd.RunCommand acCmdDeleteRecord

Exit_cmd_delete_Click:
Exit Sub

Err_cmd_delete_Click:

Select Case DataErr

Case 3200
MsgBox “you cannot delete this recordâ€
Exit Sub

Case Else
Resume Exit_cmd_delete_Click

End Select
End Sub

Now, when I click the button nothing happens. The record is not deleted but
no message box is displayed.

I have also tried adding the error handling to the forms OnError event but
when I do this, Error 3200 is still displayed. I have searched this and
other forums without finding any answers.

Any suggestions?
 
B

botuco via AccessMonster.com

Thanks ruralguy. Case Err.Number works great


Try: Select Case Err.Number
I have a one-to-many relationship from table TbX to TbY with referential
integrity turned on, cascade updates/deletes turned off. I have a form with
[quoted text clipped - 35 lines]
Any suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top