klynch0803
Registered User.
- Local time
- Today, 07:36
- Joined
- Jan 25, 2008
- Messages
- 102
I'm trying to show someones age in a form using a text box.
I have a form and it has a textbox "Birthdate" and a textbox called "CurrentDate" and I want to use another textbox "Age" to display the age. If the form is searched and displays another date it would change the age as the "Birthdate" changes.
I have this code I researched and found but it doesnt seem to work at all in my instance. I dont get any errors it just shows a blank text box. Any ideas?
----Code Start------
Private Sub Age_beforeupdate(Cancel As Integer)
Dim TotalMonths, Years, Months As Integer
TotalMonths = DateDiff("m", Birthdate, CurrentDate)
Years = TotalMonths \ 12
Months = TotalMonths Mod 12
Age = Years & " Years and " & Months & " Months"
End Sub
----End Code----
I have a form and it has a textbox "Birthdate" and a textbox called "CurrentDate" and I want to use another textbox "Age" to display the age. If the form is searched and displays another date it would change the age as the "Birthdate" changes.
I have this code I researched and found but it doesnt seem to work at all in my instance. I dont get any errors it just shows a blank text box. Any ideas?
----Code Start------
Private Sub Age_beforeupdate(Cancel As Integer)
Dim TotalMonths, Years, Months As Integer
TotalMonths = DateDiff("m", Birthdate, CurrentDate)
Years = TotalMonths \ 12
Months = TotalMonths Mod 12
Age = Years & " Years and " & Months & " Months"
End Sub
----End Code----
Last edited: