Can anyone help please

A

Arfur Pint

H

I have a form which allows the user to delete previously selected record using following code

Private Sub Yes_Click(
On Error GoTo Err_Yes_Clic

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer7
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer7
MsgBox "Record deleted
DoCmd.RunMacro "M_Close 2 Objects
Exit_Yes_Click
Exit Su

Err_Yes_Click
MsgBox "Record not deleted...
Resume Exit_Yes_Clic

End Su

I want warning messages but would prefer to write my own rather than default cascading relationships etc. I'm not sure what code I need and where to put it so any help would be much appreciated

Sheila (aka Arfur Pint
 
G

Gary Miller

You can use the SetWarnings command to turn the system
warnings off. Note how the warnings are turned back on both
in the error handling and in the exit section...

Private Sub Yes_Click()
On Error GoTo Err_Yes_Click

DoCmd.SetWarnings False ' **
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox "Record deleted"
DoCmd.RunMacro "M_Close 2 Objects"

Exit_Yes_Click:
DoCmd.SetWarnings True ' **
Exit Sub

Err_Yes_Click:
MsgBox "Record not deleted..."
DoCmd.SetWarnings True ' **
Resume Exit_Yes_Click

End Sub


--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
message
Hi

I have a form which allows the user to delete previously
selected record using following code:
Private Sub Yes_Click()
On Error GoTo Err_Yes_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox "Record deleted"
DoCmd.RunMacro "M_Close 2 Objects"
Exit_Yes_Click:
Exit Sub

Err_Yes_Click:
MsgBox "Record not deleted..."
Resume Exit_Yes_Click

End Sub

I want warning messages but would prefer to write my own
rather than default cascading relationships etc. I'm not
sure what code I need and where to put it so any help would
be much appreciated.
 
S

Scott McDaniel

Dim intResp as Integer

intResp = MsgBox("Are you sure you want to delete this
record?",vbYesNoCancel + vbExclamation, "Confirm Delete")

If intResp = vbNo or intResp = vbCancel Then
Exit Sub
Else 'user selected 'Yes'
DoCmd.SetWarnings False ' **
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox "Record deleted"
DoCmd.RunMacro "M_Close 2 Objects"
End If
 

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

Top