Hi guys!
I have the following code to set AllowEdits and Deletions to false if a date is older than 'AllowEditDate'. 'AllowEditDate' is a date in a table which has only one record and is opened by a form in 'edit' mode so that the old records can be locked by a main user.
However when this field is set to empty (i.e. the user wants none of the forms to be locked), i get an error.
Can anyone let me know how i should modify this so that i can achieve an 'if AllowEditDate is null, then do/lock nothing' kind of thing?
Sorry if i haven't been clear!
Very much appreciated!
Eddie
Old code:
I'm thinking something like this, but it doesn't work (invalid use of null on the line q = DLookup("AllowEditDate", "AllowEditsDateTable")):
I have the following code to set AllowEdits and Deletions to false if a date is older than 'AllowEditDate'. 'AllowEditDate' is a date in a table which has only one record and is opened by a form in 'edit' mode so that the old records can be locked by a main user.
However when this field is set to empty (i.e. the user wants none of the forms to be locked), i get an error.
Can anyone let me know how i should modify this so that i can achieve an 'if AllowEditDate is null, then do/lock nothing' kind of thing?
Sorry if i haven't been clear!
Very much appreciated!
Eddie
Old code:
Code:
Private Sub Form_Current()
Dim q As Date
q = DLookup("AllowEditDate", "AllowEditsDateTable")
If q >= Me.FinanaceReportDate Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End Sub
I'm thinking something like this, but it doesn't work (invalid use of null on the line q = DLookup("AllowEditDate", "AllowEditsDateTable")):
Code:
Private Sub Form_Current()
Dim q As Date
q = DLookup("AllowEditDate", "AllowEditsDateTable")
If IsNull([AllowEditDate]) Then
Me.AllowEdits = True
Me.AllowDeletions = True
Else
If q >= Me.FinanaceReportDate Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End If
End Sub
Last edited: