Suppress warnings

st3ve

Registered User.
Local time
Today, 22:02
Joined
Jan 22, 2002
Messages
75
I have a delete button on my form (command270), which removes a record from table A. Table A is related to table B with referential integrity, cascade delete and cascade update applied.

When I click on the delete button I firstly set warnings false, but I still get a message to warn me regarding related records being deleted.

If I remove the relationships and delete I still get a message to warn '1 record being deleted' etc...

How do I suppress these system messages?


My code runs as follows:

Private Sub Command270_Click()

DoCmd.SetWarnings False

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 ' acDelete
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 ' acCopy

MsgBox "This record has been deleted"
DoCmd.SetWarnings True....'etc,etc

End Sub

Thanks for any help.
 
Firstly, your DoCmd.DoMenuItem code is obsolete.
The current standard is DoCmd.RunCommand acCmdDeleteRecord

To suppress warnings we use the DoCmd.SetWarnings syntax.

i.e.

Code:
Private Sub Command270_Click()

    With DoCmd
        .SetWarnings False
        .RunCommand acCmdDeleteRecord
        .SetWarnings True
        MsgBox "This record has been deleted", vbInformation, "Record Deleted"
    End With

End Sub
 
Still warning, still annoying

Firstly, Thanks for the coding update Mile-O. The code I had was generated by the wizard when I added a button to my form.

Secondly though, I still get the warnings showing even with this new code!

Any ideas? Thanks.
 

Users who are viewing this thread

Back
Top Bottom