D
Dave
I was helped here awhile back with a select case issue and got it fixed
(Thanks)
Private Sub Q1_AfterUpdate()
Dim age
age = DateDiff("d", [Q1], Date) / 365
Select Case age
Case Is < 40
Forms!frmStudy_SPIR_COPD.pgeIneligible.SetFocus
Case Is > 72
Forms!frmStudy_SPIR_COPD.pgeIneligible.SetFocus
Reason.Value = "Out of Age Range"
End Select
End Sub
However it was pointed out that this only give the correct answer ½ the
time.
A solution was generously provided.
Function GetAge(dtmBD as Date) As Integer
GetAge = DateDiff("yyyy", dtmBD, Date) + _
(Date < DateSerial(Year(Date), Month(dtmBD), Day(dtmBD)))
End Function
Basically, this counts on the fact that a True expression has a value of
-1, and so if the current date is less than the birthdate value in the
current year, it subtracts one from the year difference between the two.
If you're using Access 95 or 97, use a Date variable rather than a
variant.
--Ken
GetAge = DateDiff("yyyy", dtmBD, Date) +(Date < DateSerial(Year(Date),
Month(dtmBD),Day(dtmBD)))
I just don't know how to really implement it.
Can anyone point me in the right direction on how to use this in my above
code.
Any help here will be appreciated.
Thanks in advance
Dave
(Thanks)
Private Sub Q1_AfterUpdate()
Dim age
age = DateDiff("d", [Q1], Date) / 365
Select Case age
Case Is < 40
Forms!frmStudy_SPIR_COPD.pgeIneligible.SetFocus
Case Is > 72
Forms!frmStudy_SPIR_COPD.pgeIneligible.SetFocus
Reason.Value = "Out of Age Range"
End Select
End Sub
However it was pointed out that this only give the correct answer ½ the
time.
A solution was generously provided.
Function GetAge(dtmBD as Date) As Integer
GetAge = DateDiff("yyyy", dtmBD, Date) + _
(Date < DateSerial(Year(Date), Month(dtmBD), Day(dtmBD)))
End Function
Basically, this counts on the fact that a True expression has a value of
-1, and so if the current date is less than the birthdate value in the
current year, it subtracts one from the year difference between the two.
If you're using Access 95 or 97, use a Date variable rather than a
variant.
--Ken
GetAge = DateDiff("yyyy", dtmBD, Date) +(Date < DateSerial(Year(Date),
Month(dtmBD),Day(dtmBD)))
I just don't know how to really implement it.
Can anyone point me in the right direction on how to use this in my above
code.
Any help here will be appreciated.
Thanks in advance
Dave