G
Guest
Hello,
I am trying to create a function that will do a date comparison and change
the background color of a field. As I need to use this on several fields, I
would like to be able to create a universal function that I can supply with
the field name and then simply call it as required. I am however having
trouble passing along the fieldname.
My function looks something very similar to this
Function Compdt(FieldName as String)
Dim leaddt as date, otherdt as date
Dim lngRed as Long
lngRed = RBG(255,0,0)
leaddt = Forms![FormName]![SubFromName].Form.Lead_Date
otherdt = Forms![FormName]![SubFromName].Form(FieldName)
If IsNull(otherdt)=False Then
If otherdt < leaddt Then otherdt.backcolor=lngRed
End If
End Function
Then I call this function is a sub like
Call Compdt(Stress_Date)
But is is giving me an error #2465 "...can't find the field '6/15/2006'"
which is the value in the field in question???
Thanking you in advance,
Daniel
I am trying to create a function that will do a date comparison and change
the background color of a field. As I need to use this on several fields, I
would like to be able to create a universal function that I can supply with
the field name and then simply call it as required. I am however having
trouble passing along the fieldname.
My function looks something very similar to this
Function Compdt(FieldName as String)
Dim leaddt as date, otherdt as date
Dim lngRed as Long
lngRed = RBG(255,0,0)
leaddt = Forms![FormName]![SubFromName].Form.Lead_Date
otherdt = Forms![FormName]![SubFromName].Form(FieldName)
If IsNull(otherdt)=False Then
If otherdt < leaddt Then otherdt.backcolor=lngRed
End If
End Function
Then I call this function is a sub like
Call Compdt(Stress_Date)
But is is giving me an error #2465 "...can't find the field '6/15/2006'"
which is the value in the field in question???
Thanking you in advance,
Daniel