Sam Summers
Registered User.
- Local time
- Today, 12:19
- Joined
- Sep 17, 2001
- Messages
- 939
Hi everyone, i have tried so many ways to do this seemingly simple task but so far no success.
I finally created a button with this code automatically generated which works:
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
-----------------------------------------------------------------------------------------------------
However when i place it all together (as below) on the doubleclick event of the form it does nothing?
On Error Resume Next
Dim Msg, Style, Title, Response, MyString
DoCmd.Beep
Msg = "Are you sure you want to delete this item?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "Confirm Delete" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
'DoCmd.RunCommand acCmdDeleteRecord
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
'Call DoCmd.RunCommand(Command:=acCmdDeleteRecord)
Me.Requery
'Me.Refresh
Else ' User chose No.
End If
I finally created a button with this code automatically generated which works:
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
-----------------------------------------------------------------------------------------------------
However when i place it all together (as below) on the doubleclick event of the form it does nothing?
On Error Resume Next
Dim Msg, Style, Title, Response, MyString
DoCmd.Beep
Msg = "Are you sure you want to delete this item?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "Confirm Delete" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
'DoCmd.RunCommand acCmdDeleteRecord
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
'Call DoCmd.RunCommand(Command:=acCmdDeleteRecord)
Me.Requery
'Me.Refresh
Else ' User chose No.
End If