' The following block of code calculates the service user's age and turns on the 'Child' radio button _
if the service user is under 18 years of age.
' This works fine in Excel 2007 but crashes out in Excel 2016 with a compile error (can't find project or library) on the highlighted line.
' It seems to me that it is due to the missing Calendar Control that does not appear to be available for the 64 bit version of Excel 2016. I could be wrong, of course, and welcome your comments.
if the service user is under 18 years of age.
' This works fine in Excel 2007 but crashes out in Excel 2016 with a compile error (can't find project or library) on the highlighted line.
' It seems to me that it is due to the missing Calendar Control that does not appear to be available for the 64 bit version of Excel 2016. I could be wrong, of course, and welcome your comments.
Code:
txtAge2 = vbNullString
txtDOB2 = vbNullString
If Range("N" & Cnt) > vbNullString And _
Range("N" & Cnt) <> "Not recorded on AIS" Then
'Call date_and_time(Range("N" & Cnt))
[highlight]txtDOB2.Value = Format(Range("N" & Cnt), "dd/mm/yyyy")[/highlight]
FirstDate = txtDOB2
SecondDate = Date
Age = Year(SecondDate) - Year(FirstDate)
Mth = Month(SecondDate) - Month(FirstDate)
Day1 = Day(SecondDate) - Day(FirstDate)
Select Case Mth
Case Is < 0
txtAge2 = Age - 1
Case 0
Select Case Day1
Case Is < 0
txtAge2 = Age - 1
Case Else
txtAge2 = Age
End Select
Case Else
txtAge2 = Age
End Select
If txtAge2 < 18 Then
opChild2.Value = True
Else
opChild2.Value = False
End If
Else
txtDOB2 = ""
txtAge = vbNullString
End If