Groundrush
Registered User.
- Local time
- Today, 18:23
- Joined
- Apr 14, 2002
- Messages
- 1,376
Any suggestions please?
Been experimenting on some code to prevent deletion or changes to records that meet certain conditions.
The problem I am having is the code is contradicating each other preventing some of the records to be locked down.
Is there a better way to write this code?
Rules are:
Edits allowed if invoice date not reached
Edits allowed if within 21 day but NOT if invoice date is reached
Edits prevented if invoiced date reached and if records still within 21 days
Edits prevented if invoiced date reached & records past 21 days
Thanks
Been experimenting on some code to prevent deletion or changes to records that meet certain conditions.
The problem I am having is the code is contradicating each other preventing some of the records to be locked down.
Code:
Private Sub Form_Current()
'Code 1 - Prevent edits if 21 day period has lapsed
If TestDate2(Me.txtStartedHidden) > 0 Then
MsgBox "Editing NOT allowed - 21 day time period has been reached"
Me.txtBasic.Locked = True
Me.cmdDelete.Enabled = False
'Code 2 - Prevent edits once invoice date has been reached.
If CDate(Me.cboJobNo.Column(8)) <= Date Then
MsgBox "Editing NOT allowed - Invoice date has been reached"
Me.txtBasic.Locked = True
Me.cmdDelete.Enabled = False
Else
MsgBox "Editing is allowed - Invoice date not reached & still within 21 days"
Me.txtBasic.Locked = False
Me.cmdDelete.Enabled = True
End If
End If
End Sub
Is there a better way to write this code?
Rules are:
Edits allowed if invoice date not reached
Edits allowed if within 21 day but NOT if invoice date is reached
Edits prevented if invoiced date reached and if records still within 21 days
Edits prevented if invoiced date reached & records past 21 days
Thanks