I am having the following problem:
When I tab from box to box after I lose focus on the box that I ask the user to enter the childs date of birth, a runtime error, "Error 13" occurs (a data type mismatch error). If I manually click in each box and don't tab, this problem does not occur.
Here is the code that seems to be problematic when I tab
(someone very kindly on tek-tips gave me this code to accurately figure out someones Age - it works well!)
Private Sub maskDateOfBirthChild_LostFocus()
Dim basAge As String
basAge = DateDiff("yyyy", maskDateOfBirthChild.Text, Date)
basAge = basAge + (DateSerial(Year(Date), Month(maskDateOfBirthChild.Text), Day(maskDateOfBirthChild.Text)) > Date)
txtAgeChild.Text = basAge
End Sub
If I manually click in the date of birth box and enter the date of birth and then click in any other box the accurate age shows up in the age box. However if I tab into the date of birth box, enter the date of birth, the press tab again the runtime error "Error 13" shows up.
Can anyone help me solve this problem?
Thank you!
When I tab from box to box after I lose focus on the box that I ask the user to enter the childs date of birth, a runtime error, "Error 13" occurs (a data type mismatch error). If I manually click in each box and don't tab, this problem does not occur.
Here is the code that seems to be problematic when I tab
(someone very kindly on tek-tips gave me this code to accurately figure out someones Age - it works well!)
Private Sub maskDateOfBirthChild_LostFocus()
Dim basAge As String
basAge = DateDiff("yyyy", maskDateOfBirthChild.Text, Date)
basAge = basAge + (DateSerial(Year(Date), Month(maskDateOfBirthChild.Text), Day(maskDateOfBirthChild.Text)) > Date)
txtAgeChild.Text = basAge
End Sub
If I manually click in the date of birth box and enter the date of birth and then click in any other box the accurate age shows up in the age box. However if I tab into the date of birth box, enter the date of birth, the press tab again the runtime error "Error 13" shows up.
Can anyone help me solve this problem?
Thank you!