Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping standard Access messages

Status
Not open for further replies.

miow

Programmer
Apr 15, 2006
14
GB
Hi

I am trying to find out the error code for the standard Access message of "You are about to delete 1 records, are you sure you want to delete this?". This is presented to a user when they try to delete a record. I want to trap this error so that i can find out what the error number so that I can display my own customised message. I have done the following:
Added the following the form I am trying to write the customised message for.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Debug.Print "DataErr = "; DataErr
End Sub

I can't seem to trap the error. I have looked at microsofts articles and as I far as I can see, adding this code to the form and then trying to delete a record should produce the error message in the immediate window....this isn't happening for some reason and I can't see where I am going wrong. Any advice greatly appreciated in advance.

Thanks

Miow
 
There is no trapable error for this. But, you can post your own message and surpress the MS Access message.
Here is a sample of one I just wrote to test this. By setting "Response" to 0, Access will not post it's own message.
Code:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
dim RetVal as Variant
  RetVal = MsgBox("Delete this Record?", vbQuestion + vbYesNo, "Please respond")
  If RetVal <> vbYes Then
    Cancel = True
  End If
  Response = 0
End Sub


 
Hi VicRauch

Thanks for the work around, I will take a shot at this and let you know how I get one...oh sometimes these standard access messages can be annoying!

thanks

Miow
 
this isn't a error, it's a warning, and I always disable them...

docmd.setwarnings false
some sql and stuff
docmd.setwarnings true

if there's any confirmation needed, I'll just pop in a message box in there somewhere...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top