I ahve a function that prepares a date for a get age function but mine is complaining :
compile error byref argument type mismatch.
I can see why I have the error but I am not sure how to correct it.
regards
Peter
Public Function getLearndirectAge(enrolmentdate As String, Dob As String) As Integer
Dim enrolmentDateIn, dobin As Date
Dim learndirectAge As Integer
Dim StrYear, StrPreviousYear, StrAugust As String
StrPreviousYear = Format(Now(), "yyyy") - 1 & "#"
StrAugust = "#31/8/" & StrPreviousYear
dobin = "#" & dob & "#"
' i think the problem his here with the format of my dates
getLearndirectAge = dhAge(dobin, StrAugust)
End Function
Public Function dhAge(dtmBD As Date, Optional dtmDate As Date = 0) _
As Integer
' From "Visual Basic Language Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 2000; Sybex, Inc. All rights reserved.
' Thanks to Peter Mundy, on comp.databases.ms-access
' for fixing up a flaw in the original logic of this
' procedure.
Dim intAge As Integer
If dtmDate = 0 Then
' Did the caller pass in a date? If not, use
' the current date.
dtmDate = Date
End If
intAge = DateDiff("yyyy", dtmBD, dtmDate)
If dtmDate < DateAdd("yyyy", intAge, dtmBD) Then
intAge = intAge - 1
End If
dhAge = intAge
End Function
compile error byref argument type mismatch.
I can see why I have the error but I am not sure how to correct it.
regards
Peter
Public Function getLearndirectAge(enrolmentdate As String, Dob As String) As Integer
Dim enrolmentDateIn, dobin As Date
Dim learndirectAge As Integer
Dim StrYear, StrPreviousYear, StrAugust As String
StrPreviousYear = Format(Now(), "yyyy") - 1 & "#"
StrAugust = "#31/8/" & StrPreviousYear
dobin = "#" & dob & "#"
' i think the problem his here with the format of my dates
getLearndirectAge = dhAge(dobin, StrAugust)
End Function
Public Function dhAge(dtmBD As Date, Optional dtmDate As Date = 0) _
As Integer
' From "Visual Basic Language Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 2000; Sybex, Inc. All rights reserved.
' Thanks to Peter Mundy, on comp.databases.ms-access
' for fixing up a flaw in the original logic of this
' procedure.
Dim intAge As Integer
If dtmDate = 0 Then
' Did the caller pass in a date? If not, use
' the current date.
dtmDate = Date
End If
intAge = DateDiff("yyyy", dtmBD, dtmDate)
If dtmDate < DateAdd("yyyy", intAge, dtmBD) Then
intAge = intAge - 1
End If
dhAge = intAge
End Function