I use the following code to stop users from entering a date on a record when that date has already been used in another record:
If Not IsNull(DLookup("[ActivityDate]", "[tblActivitySheet]", "[ActivityDate]=#" & Format([ActivityDate], "yyyy-mm-dd") & "#")) Then
MsgBox "There is already an Activity Sheet for this date, please search by date to locate..."
Cancel = True
End If
The record in the table is set to "No Duplicates", so I am trying to trap the error and add a custom message.
This works so far. The problem I am having is that I would like to make the Date field Null and "Undo" or "Delete" that record that was started once this error is trapped like this.
Right now the user realizes that date already exhist once the above MsgBox tells him so. So he then wants to leave this record and go to the record that already exhist with that date. But since this record has already started, it wont let him leave until he finishes completing this record...ie mandatory fields and a new date entered...etc...
If Not IsNull(DLookup("[ActivityDate]", "[tblActivitySheet]", "[ActivityDate]=#" & Format([ActivityDate], "yyyy-mm-dd") & "#")) Then
MsgBox "There is already an Activity Sheet for this date, please search by date to locate..."
Cancel = True
End If
The record in the table is set to "No Duplicates", so I am trying to trap the error and add a custom message.
This works so far. The problem I am having is that I would like to make the Date field Null and "Undo" or "Delete" that record that was started once this error is trapped like this.
Right now the user realizes that date already exhist once the above MsgBox tells him so. So he then wants to leave this record and go to the record that already exhist with that date. But since this record has already started, it wont let him leave until he finishes completing this record...ie mandatory fields and a new date entered...etc...