I'm sure this probably has a simple solution but somehow I'm having some issues trying to figure out how to prevent a form to insert a record once it has been updated that day; yet still allow edit
For example:
If a record has been entered for today and someone tried to add a new one later that same day, it would prevent that user to add another record but allow them to edit that record if necessary.
The only time I would like for users to insert a record is on a different date in the future.
I've tried using BeforeUpdate and BeforeInsert but it won't let me save in the end and gives me errors.
My form has the following fields:
Date, Orders, Weight, Costs
Any assistance would be greatly appreciated. Thank you!
For example:
If a record has been entered for today and someone tried to add a new one later that same day, it would prevent that user to add another record but allow them to edit that record if necessary.
The only time I would like for users to insert a record is on a different date in the future.
I've tried using BeforeUpdate and BeforeInsert but it won't let me save in the end and gives me errors.
My form has the following fields:
Date, Orders, Weight, Costs
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim dToday As Date
dToday = Format(Now(), "Medium Date")
If Me.txtDate.Value = dToday And Not IsNull(txtOrders) And Not IsNull(txtWeight) And Not IsNull(txtCost) Then
MsgBox "Record has been updated TODAY, " + Format(Now(), "dd mmmm yyyy"), vbOKOnly
End If
DoCmd.GoToRecord , , acLast
DoCmd.CancelEvent
End Sub
Any assistance would be greatly appreciated. Thank you!