Dairy Farmer
Registered User.
- Local time
- Today, 09:30
- Joined
- Sep 23, 2010
- Messages
- 244
Need help finishing this code please. Access 2k7.
Existing record - Deletes (working)
New record, dirty - Undo (working)
New record, no data - Undo (working)
No records - goes to "Existing record"
Existing record - Deletes (working)
New record, dirty - Undo (working)
New record, no data - Undo (working)
No records - goes to "Existing record"
Code:
Private Sub Button_Delete_Click()
Dim Msg, Style, Title, Response, MyString
Dim Cancel As String
'Existing record
If (Not Me.NewRecord) Then
Msg = "Are you sure you want to delete this entry?" & vbNewLine & "This CANNOT be undone!"
Style = vbOKCancel + vbQuestion + vbDefaultButton2
Title = "Delete An Entry"
Response = MsgBox(Msg, Style, Title)
If Response = vbCancel Then
MyString = "Cancel"
Cancel = True
DoCmd.GoToControl "ProblemDate"
Else
MyString = "OK"
DoCmd.RunCommand acCmdDeleteRecord
Me.AllowAdditions = False
End If
End If
'New record dirty
If (Me.NewRecord And Me.Dirty) Then
Msg = "Are you sure you want to discard this entry?"
Style = vbOKCancel + vbQuestion + vbDefaultButton2
Title = "Discard An Entry"
Response = MsgBox(Msg, Style, Title)
If Response = vbCancel Then
MyString = "Cancel"
Cancel = True
DoCmd.GoToControl "ProblemDate"
Me.AllowAdditions = False
Else
MyString = "OK"
DoCmd.RunCommand acCmdUndo
Me.AllowAdditions = False
End If
End If
'New record no data
If (Me.NewRecord And Not Me.Dirty) Then
Me.AllowAdditions = False
End If
End Sub