dbTalk Databases Forums  

Access Forms

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


Discuss Access Forms in the comp.database.ms-access forum.



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

Default Access Forms - 05-30-2004 , 04:25 AM






Can someone help!

I want to insert a feild on a Access 2000 database form where you insert
Date of Birth in another feild I want in to automaticly caculate how old the
person is in years can someone tell me how to do this.

cheers
Dave



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

Default Re: Access Forms - 05-30-2004 , 04:55 AM






1. Go to the module section
2. add module
3. add the following text to the module

Public Function YearsOld(FrmN As String, CtlN As String) As Byte
On Error GoTo err
Dim DOB As Date
DOB = Forms(FrmN).Controls(CtlN)
If Not IsDate(DOB) Then GoTo xit
YearsOld = DateDiff("y", DOB, DATE)
xit:
Exit Function
err:
Resume xit
End Function

On the DOB field, open the properties sheet and go to the afterupdate event

Click on the ... and add the following **code** in the forms module window:

Me.Controls("x").Value = YearsOld(Me.Name, "y")

where x = the name of the control that shows the number of years and y = the
control where people enter the their DOB.

Any additional questions??? Please ask.


"Dave PNNZ" <drakej37 (AT) hotmail (DOT) com> wrote

Quote:
Can someone help!

I want to insert a feild on a Access 2000 database form where you insert
Date of Birth in another feild I want in to automaticly caculate how old
the
person is in years can someone tell me how to do this.

cheers
Dave



---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004




Reply With Quote
  #3  
Old   
Jeremy B. Shapiro
 
Posts: n/a

Default Re: Access Forms - 05-30-2004 , 12:16 PM



FYI,

DateDiff("y",DOB,DATE) does NOT give the correct age... That only gives the
difference in years so the month and day do not come into play. Which means
that if your birthday is tomorrow, your age will be same today as it is
tomorrow (and anything before tomorrow will be wrong). If you need more
clarification, let me know...

Best,

--
Jeremy Shapiro
Asandia, Corp.
www.asandia.com
1.866.ASANDIA (272.6342)

"WindAndWaves" <access (AT) ngaru (DOT) com> wrote

Quote:
1. Go to the module section
2. add module
3. add the following text to the module

Public Function YearsOld(FrmN As String, CtlN As String) As Byte
On Error GoTo err
Dim DOB As Date
DOB = Forms(FrmN).Controls(CtlN)
If Not IsDate(DOB) Then GoTo xit
YearsOld = DateDiff("y", DOB, DATE)
xit:
Exit Function
err:
Resume xit
End Function

On the DOB field, open the properties sheet and go to the afterupdate
event

Click on the ... and add the following **code** in the forms module
window:

Me.Controls("x").Value = YearsOld(Me.Name, "y")

where x = the name of the control that shows the number of years and y =
the
control where people enter the their DOB.

Any additional questions??? Please ask.


"Dave PNNZ" <drakej37 (AT) hotmail (DOT) com> wrote in message
news:40b9a8ab (AT) news (DOT) compass.net.nz...
Can someone help!

I want to insert a feild on a Access 2000 database form where you insert
Date of Birth in another feild I want in to automaticly caculate how old
the
person is in years can someone tell me how to do this.

cheers
Dave




---
Please immediately let us know (by phone or return email) if (a) this
email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004






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.