J
JudyB
I have the following function:
Public Function CalcWeeks(DateStart As Variant, DateEnd As Variant) As Single
If IsNull(DateStart) Then
CalcWeeks = Null
Exit Function
End If
CalcWeeks = DateDiff("ww", DateStart, Nz(DateEnd, Date))
End Function
I was concerned that the code above CalcWeeks = ...Nz(DateEnd, Date)) since
it did not have the parentheses at the end ...Date())) but the system
converts it back to the way it is shown above and I was told not to worry
about it that it would still work.
I am using this function in a query and it works great. I have been trying
to use it in my subform as well and it just doesn't work. It returns the
number "0". This is the code that I have used in the control source of the
WeeksService field:
=CalcWeeks([DateStart],[DateEnd])
I can type in the code DateDiff("ww", DateStart, Nz(DateEnd, Date)) and it
works great. Can someone please tell me why the function is not working in
the subform but works in the query and how to correct the problem? Any help
would be greatly appreciated.
Thanks in advance. This is really wearing me down and I have much more work
to do before completing this database.
Public Function CalcWeeks(DateStart As Variant, DateEnd As Variant) As Single
If IsNull(DateStart) Then
CalcWeeks = Null
Exit Function
End If
CalcWeeks = DateDiff("ww", DateStart, Nz(DateEnd, Date))
End Function
I was concerned that the code above CalcWeeks = ...Nz(DateEnd, Date)) since
it did not have the parentheses at the end ...Date())) but the system
converts it back to the way it is shown above and I was told not to worry
about it that it would still work.
I am using this function in a query and it works great. I have been trying
to use it in my subform as well and it just doesn't work. It returns the
number "0". This is the code that I have used in the control source of the
WeeksService field:
=CalcWeeks([DateStart],[DateEnd])
I can type in the code DateDiff("ww", DateStart, Nz(DateEnd, Date)) and it
works great. Can someone please tell me why the function is not working in
the subform but works in the query and how to correct the problem? Any help
would be greatly appreciated.
Thanks in advance. This is really wearing me down and I have much more work
to do before completing this database.