Rx_
Nothing In Moderation
- Local time
- Yesterday, 21:54
- Joined
- Oct 22, 2009
- Messages
- 2,803
Example code - no question - comments welcome
On a table, added a yes/no field named [Deleted]
With the current record in a form, the user can click a command button that ask them if they want to mark this record as deleted.
The the Delete field is changed. The user can use a list box to mark others (the list box shows the status).
Instead of actually deleting records, marking a record as deleted provides another level of reporting.
the if me.dirty line ensures that there are no edits and makes sure that one date field is completed. It is not a required field, but a "good to know" field.
On a table, added a yes/no field named [Deleted]
With the current record in a form, the user can click a command button that ask them if they want to mark this record as deleted.
The the Delete field is changed. The user can use a list box to mark others (the list box shows the status).
Instead of actually deleting records, marking a record as deleted provides another level of reporting.
the if me.dirty line ensures that there are no edits and makes sure that one date field is completed. It is not a required field, but a "good to know" field.
Code:
Private Sub cmdDeleteRecord_Click()
On Error GoTo Proc_error
Dim rsMarkDeleted As dao.Recordset
Dim Answer As String
If Me.Dirty = False And Not IsNull(Me.txtDateSubmitted) Then
Answer = MsgBox("This will Mark the Record for Deletion, are you absolutely sure?", vbCritical + vbYesNo, "WARNING - No Undo")
If Answer = vbNo Then
MsgBox "Nothing changed", vbOKOnly, "Canceled Operation"
Else
Set rsMarkDeleted = Me.Recordset
rsMarkDeleted.Edit
rsMarkDeleted.Fields("Deleted").Value = True
rsMarkDeleted.Update
MsgBox "File was marked as Deleted, Please close and re-open Notification form to see change", vbOKOnly, "Record Marked as Deleted - Chooe another or Close / Reopen to See changes"
End If
Else
MsgBox "Date Submitted is not completed or the record is still locked for editing", vbOKOnly, "Cancel Mark for Editing"
End If
Proc_exit:
On Error Resume Next
Exit Sub
Proc_error:
Select Case Err.Number
' Case ###
Case Else
'
End Select
End Sub