473,513 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating age

I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).

I would like that when users open the form, a message should alert if
that person is over age 96 (yes I do have old clients...). If under
age 96, I would not like any message.

The match should therefore be done between the date stored in the DOB
field and the current date.

Is there a code to do this and where should it go.
Nov 12 '05 #1
6 3097
Copy the code from this link into a standard module:
http://members.iinet.net.au/~allenbrowne/func-08.html

You can then put a text box on your form, with this its ContorlSource:
=IIf(Age([DOB]) >= 96, "Geriatric warning", Null)

The function allows you to specify a death date if appropriate.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paolo" <jp***@tin.it> wrote in message
news:9f**************************@posting.google.c om...
I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).

I would like that when users open the form, a message should alert if
that person is over age 96 (yes I do have old clients...). If under
age 96, I would not like any message.

The match should therefore be done between the date stored in the DOB
field and the current date.

Is there a code to do this and where should it go.

Nov 12 '05 #2
If it is only to happen when the form happens, then in either it's On Open
or On Load events add

If DateDiff("yyyy",Me!DOBField,Date) >= 96 Then
MsgBox ("Message Here", ButtonStyle, Title)
end if

"Paolo" <jp***@tin.it> wrote in message
news:9f**************************@posting.google.c om...
I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).

I would like that when users open the form, a message should alert if
that person is over age 96 (yes I do have old clients...). If under
age 96, I would not like any message.

The match should therefore be done between the date stored in the DOB
field and the current date.

Is there a code to do this and where should it go.

Nov 12 '05 #3
On 30 Jan 2004 06:53:03 -0800, jp***@tin.it (Paolo) wrote:
I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).
Well... actually, it stores the date of birth as a Double Float
number, a count of days and fractions of a day since midnight,
December 30, 1899. The display format is irrelevant to the problem.
I would like that when users open the form, a message should alert if
that person is over age 96 (yes I do have old clients...). If under
age 96, I would not like any message.

The match should therefore be done between the date stored in the DOB
field and the current date.

Is there a code to do this and where should it go.


I'd suggest code in the Form's Current event to bring up a message
whenever someone either opens the form, or navigates to an the record
of such an Esteemed Elder (note: in Chinese culture, someone who
reaches the age of 96 is considered an "honarary centenarian"). Try
code like

Private Sub Form_Current()
Dim iAge As Integer
iAge = DateDiff("yyyy", [DOB], Date())
' Correct for people whose birthday has not yet arrived
If DateSerial(Year(Date()), Month([DOB]), Day([DOB])) > Date() Then
iAge = iAge - 1
End If
If iAge >= 96 Then
Msgbox "This person is " & iAge & " years old, handle with respect!"
End If
End Sub

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
Nov 12 '05 #4
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:a2********************************@4ax.com:
On 30 Jan 2004 06:53:03 -0800, jp***@tin.it (Paolo) wrote:
I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).


Well... actually, it stores the date of birth as a Double Float
number


It stores it in 8 bytes.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #5
CDB
Being two 4-byte integers, IIRC.

Clive
"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:a2********************************@4ax.com:
On 30 Jan 2004 06:53:03 -0800, jp***@tin.it (Paolo) wrote:
I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).


Well... actually, it stores the date of birth as a Double Float
number


It stores it in 8 bytes.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)

Nov 12 '05 #6
Thanks, this is exactly what I am looking for. There is still one
debugging problem on the line: iAge = DateDiff("yyyy", [DOB], Date())

Any idea?

John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message news:<a2********************************@4ax.com>. ..
On 30 Jan 2004 06:53:03 -0800, jp***@tin.it (Paolo) wrote:
I have a form on which I have a field named DOB which stores the
client's date of birth (mm/dd/yyyy).


Well... actually, it stores the date of birth as a Double Float
number, a count of days and fractions of a day since midnight,
December 30, 1899. The display format is irrelevant to the problem.
I would like that when users open the form, a message should alert if
that person is over age 96 (yes I do have old clients...). If under
age 96, I would not like any message.

The match should therefore be done between the date stored in the DOB
field and the current date.

Is there a code to do this and where should it go.


I'd suggest code in the Form's Current event to bring up a message
whenever someone either opens the form, or navigates to an the record
of such an Esteemed Elder (note: in Chinese culture, someone who
reaches the age of 96 is considered an "honarary centenarian"). Try
code like

Private Sub Form_Current()
Dim iAge As Integer
iAge = DateDiff("yyyy", [DOB], Date())
' Correct for people whose birthday has not yet arrived
If DateSerial(Year(Date()), Month([DOB]), Day([DOB])) > Date() Then
iAge = iAge - 1
End If
If iAge >= 96 Then
Msgbox "This person is " & iAge & " years old, handle with respect!"
End If
End Sub

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8791
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
0
2255
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event...
1
3220
by: Joe Bongiardina | last post by:
What does the message "calculating...." mean in the lower left status area of a form? I have a form with no calculated, concatenated or lookup fields, yet it displays this msg. The form takes...
1
2367
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
0
1771
by: robin9876 | last post by:
In an Access 2000 database on some forms 'Calculating...' is continuously displayed in the status bar window and the text of the control is automatically selected. The only workaround is switching...
5
11938
by: sugaray | last post by:
Hi, my problem with calculating the size of an array is when I pass an array as a parameter to a function which perform the calculation, the result never comes right, like below: int...
25
4996
by: Umesh | last post by:
i want to calculate the time required to execute a program. Also i want to calcute the time remaining for the execution of the program. how can i do that? pl mention some good websites for...
1
2409
by: laredotornado | last post by:
Hi, Can anyone recommend a free script for calculating UPS shipping? I am familiar with the script written in 2000 by Jason Costomiris, but UPS is using an XML interface and I wondered if...
4
2082
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
Say I have a class like, class Sample { public decimal first = 10; public decimal second = 20; } I have initialized it
4
4008
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.