Can anyone help please

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
Back
Top