dbTalk Databases Forums  

Date of Birth

comp.database.ms-access comp.database.ms-access


Discuss Date of Birth in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Paolo
 
Posts: n/a

Default Date of Birth - 08-12-2003 , 04:33 AM






Hello,
I have a table named CUSTOMERS with a field named DOB. It has a
mm/dd/yyyy format. It displays dates of birth.

I would like to add on a form two text boxes named txtDOB and txtAGE.

The txtDOB will have as record source the table CUSTOMERS and the
field DOB.
I would like to add the unbound txtAGE control to convert the Date of
birth to Age.
Can any one tell me how and where I should write the the code? Thanks.

Reply With Quote
  #2  
Old   
janthony
 
Posts: n/a

Default Re: Date of Birth - 08-12-2003 , 10:20 AM






jprma (AT) tin (DOT) it (Paolo) wrote in message news:<9f41a860.0308120133.3ebe5544 (AT) posting (DOT) google.com>...
Quote:
Hello,
I have a table named CUSTOMERS with a field named DOB. It has a
mm/dd/yyyy format. It displays dates of birth.

I would like to add on a form two text boxes named txtDOB and txtAGE.

The txtDOB will have as record source the table CUSTOMERS and the
field DOB.
I would like to add the unbound txtAGE control to convert the Date of
birth to Age.
Can any one tell me how and where I should write the the code? Thanks.
First, to set the field for the DOB, you can use the forms wizard to
help with that, by simply selecting the table and that field.
Otherwise you can add the field and change the record source.

As for your second question, what are you wanting to convert the date
to?


Reply With Quote
  #3  
Old   
Paolo
 
Posts: n/a

Default Re: Date of Birth - 08-13-2003 , 02:16 AM



Thanks,
yes, what I need is simply convert the date of birth to age/months.
thanks.
janthony (AT) harrahs (DOT) com (janthony) wrote in message news:<41de23b5.0308120720.7b932f6e (AT) posting (DOT) google.com>...
Quote:
jprma (AT) tin (DOT) it (Paolo) wrote in message news:<9f41a860.0308120133.3ebe5544 (AT) posting (DOT) google.com>...
Hello,
I have a table named CUSTOMERS with a field named DOB. It has a
mm/dd/yyyy format. It displays dates of birth.

I would like to add on a form two text boxes named txtDOB and txtAGE.

The txtDOB will have as record source the table CUSTOMERS and the
field DOB.
I would like to add the unbound txtAGE control to convert the Date of
birth to Age.
Can any one tell me how and where I should write the the code? Thanks.

First, to set the field for the DOB, you can use the forms wizard to
help with that, by simply selecting the table and that field.
Otherwise you can add the field and change the record source.

As for your second question, what are you wanting to convert the date
to?

Reply With Quote
  #4  
Old   
Paul R
 
Posts: n/a

Default Re: Date of Birth - 08-15-2003 , 03:02 AM



You are welcome to use the following code. It will return an age in
years only so you might want to adapt it.

You could either use the code behind the form and call it at form open
or create a module that you would then be able to use elsewhere.

code:

Function AgeNow(DOB As Date) As Integer
'calculates age in years based upon date of birth
If DOB > 0 Then

If DatePart("m", DOB) < DatePart("m", Date) Or (DatePart("m", DOB)
= DatePart("m", Date) And DatePart("d", DOB) < DatePart("d", Date))
Then
'they've already had their birthday this year
AgeNow = DateDiff("yyyy", DOB, Date)
Else: AgeNow = DateDiff("yyyy", DOB, Date) - 1

End If
End If

End Function

Hope this helps, it is probably not the neatest way of doing it but it
works.

Paul

jprma (AT) tin (DOT) it (Paolo) wrote in message news:<9f41a860.0308122316.2b86b619 (AT) posting (DOT) google.com>...
Quote:
Thanks,
yes, what I need is simply convert the date of birth to age/months.
thanks.
janthony (AT) harrahs (DOT) com (janthony) wrote in message news:<41de23b5.0308120720.7b932f6e (AT) posting (DOT) google.com>...
jprma (AT) tin (DOT) it (Paolo) wrote in message news:<9f41a860.0308120133.3ebe5544 (AT) posting (DOT) google.com>...
Hello,
I have a table named CUSTOMERS with a field named DOB. It has a
mm/dd/yyyy format. It displays dates of birth.

I would like to add on a form two text boxes named txtDOB and txtAGE.

The txtDOB will have as record source the table CUSTOMERS and the
field DOB.
I would like to add the unbound txtAGE control to convert the Date of
birth to Age.
Can any one tell me how and where I should write the the code? Thanks.

First, to set the field for the DOB, you can use the forms wizard to
help with that, by simply selecting the table and that field.
Otherwise you can add the field and change the record source.

As for your second question, what are you wanting to convert the date
to?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.