I built a simple function to return the age based on a client’s date of birth and the date of entry. If called from the date of birth field on the main function, it works beautifully. The identical call from the subform within that form fails with a “Type Mismatch” error. When debugging, I check in the Immediate Window by doing “? IsDate(dteDOB)” and “? IsDate(dteEntry)” and of course, they both are. So why should a function work in one instance and not in the other?
Probably the simplest fix is to send the dates as strings and convert them, but has anybody else seen this kind of problem?
==========
Public Function AgeAtIntake(dteDOB As Date, dteEntry As Date) As Integer
Dim intAge As Integer
intAge = DateDiff("yyyy", dteDOB, dteEntry)
If Format(dteDOB, "mmdd") > Format(dteEntry, "mmdd") Then
intAge = intAge - 1
End If
AgeAtIntake = intAge
End Function
===========
Tobi Hoffman
Dept. of Youth Services
Please zip all files prior to uploading to Files section.
Tidak ada komentar:
Posting Komentar