L
Liz James
Happy New Year to you all
My app has several forms where users enter or update data.
There are 2 fields for date: ADate and CDate where Adate is the assessment
date and Cdate is the completion date, as txtADate and txtCDate.
I am creating a public function to call from a before update event of the
forms.
The function will check if the date is between 1 Jan 1998 and today’s date.
I can’t figure out how to check for the value of the date in a public
function.
If I write separate code for each form I put
If txtADate <= #1/1/1998# Or txtADate > Now Then
Cancel = True
MsgBox "Date must be between 1998 and today's date.", , "Error"
End if
If txtCDate <= #1/1/1998# Or txtCDate > Now Then
MsgBox "Date must be between 1998 and today's date.", , "Error"
End if
My public function looks like this:
Public Function fnDateOutsideRange(frm As Form) As Boolean
Dim ctl As Access.Control
For Each ctl In frm.Controls
With ctl
If .Tag = "DateRange" Then
boolDate = False
* * How do I say if the date <= #1/1/1998# or > Now Then
For both txt controls txtADate and txtCDate ?**
boolDate = True
End If
If boolDate Then
MsgBox "Date must be between 1998 and today's date.", , "Error"
End If
My app has several forms where users enter or update data.
There are 2 fields for date: ADate and CDate where Adate is the assessment
date and Cdate is the completion date, as txtADate and txtCDate.
I am creating a public function to call from a before update event of the
forms.
The function will check if the date is between 1 Jan 1998 and today’s date.
I can’t figure out how to check for the value of the date in a public
function.
If I write separate code for each form I put
If txtADate <= #1/1/1998# Or txtADate > Now Then
Cancel = True
MsgBox "Date must be between 1998 and today's date.", , "Error"
End if
If txtCDate <= #1/1/1998# Or txtCDate > Now Then
MsgBox "Date must be between 1998 and today's date.", , "Error"
End if
My public function looks like this:
Public Function fnDateOutsideRange(frm As Form) As Boolean
Dim ctl As Access.Control
For Each ctl In frm.Controls
With ctl
If .Tag = "DateRange" Then
boolDate = False
* * How do I say if the date <= #1/1/1998# or > Now Then
For both txt controls txtADate and txtCDate ?**
boolDate = True
End If
If boolDate Then
MsgBox "Date must be between 1998 and today's date.", , "Error"
End If