PC Review


Reply
Thread Tools Rate Thread

Calculating Birthdates

 
 
=?Utf-8?B?U2FyYWhMeW4=?=
Guest
Posts: n/a
 
      19th Jun 2006
I am having problems. I am trying to get the birthdates to calculate and show
up in a form. I have been use this

Age:
Abs(DateDiff("yyyy",DOB,Date())+(Format(Date(),"mmdd")<Format(DOB,"mmdd")))

In my query and I get an error of #Name? in my form where the birthday is to
calculate If some one could help me out.

Please advise.
 
Reply With Quote
 
 
 
 
Cilla
Guest
Posts: n/a
 
      19th Jun 2006
SarahLyn wrote:
> I am having problems. I am trying to get the birthdates to calculate and show
> up in a form. I have been use this
>
> Age:
> Abs(DateDiff("yyyy",DOB,Date())+(Format(Date(),"mmdd")<Format(DOB,"mmdd")))
>
> In my query and I get an error of #Name? in my form where the birthday is to
> calculate If some one could help me out.
>
> Please advise.


The code is good except you do not have brackets around the DOB field.
Try an unbound field in the form with the same calc below as the
control source for the unbound field..

=Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))

should work fine

If you are pulling it from a query make sure you have no format on the
field in the form.

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      20th Jun 2006
It is difficult to see what is the purpose of the Abs() function in this
expression. I don't think it's right. Try this...
Age:
DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd"))

--
Steve Schapel, Microsoft Access MVP

Cilla wrote:
> =Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      20th Jun 2006
It is difficult to see what is the purpose of the Abs() function in this
expression. I don't think it's right. Try this...
Age:
DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd"))

--
Steve Schapel, Microsoft Access MVP

Cilla wrote:
> =Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))

 
Reply With Quote
 
=?Utf-8?B?QmVyZWs=?=
Guest
Posts: n/a
 
      22nd Jul 2006
I trying to determine the age of a person and I was using this command in the
default value:

DateDiff("yyyy",[birth_date],Date())

and when i try to save the table it says

"The database engine does not recognize either the field 'birth_date' in a
validation expression, or the default value in the table 'general'

I believe it is the latter situation, but not sure how to fix it

Thanks
 
Reply With Quote
 
strive4peace
Guest
Posts: n/a
 
      22nd Jul 2006
Hi Berek ,

Since Age is a calculation (and will change), it is something that
should be shown on a form or report rather than stored. You can't use
equations like that in the DefaultValue property of a table, but you can
set a DefaultValue like this for a form control ... but, in this case,
you wouldn't do that because the equation should be preceeded by an
equal sign (=) and used as the ControlSource of a calculated control

You should not put data directly into tables anyway.

Also, the equation you are using won't work properly if the person was
born in December and the current month is July because Access will just
take the difference of the years.

This was posted by Ricky Hicks:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the current age .. use:

DateDiff("yyyy", [DOBField], Date()) +
(Date() < DateSerial(Year(Date()), Month([DOBField]), Day([DOBField])))

"DOBField" should be the name of the field that contains the Date of
Birth value ...
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Warm Regards,
Crystal
*
(: have an awesome day
*
MVP Access



Berek wrote:
> I trying to determine the age of a person and I was using this command in the
> default value:
>
> DateDiff("yyyy",[birth_date],Date())
>
> and when i try to save the table it says
>
> "The database engine does not recognize either the field 'birth_date' in a
> validation expression, or the default value in the table 'general'
>
> I believe it is the latter situation, but not sure how to fix it
>
> Thanks

 
Reply With Quote
 
=?Utf-8?B?QmVyZWs=?=
Guest
Posts: n/a
 
      27th Jul 2006
Thanks a lot, that was very useful and makes much more sense. There is no
need to store that info.... duh

Thanks again

Berek



"strive4peace" wrote:

> Hi Berek ,
>
> Since Age is a calculation (and will change), it is something that
> should be shown on a form or report rather than stored. You can't use
> equations like that in the DefaultValue property of a table, but you can
> set a DefaultValue like this for a form control ... but, in this case,
> you wouldn't do that because the equation should be preceeded by an
> equal sign (=) and used as the ControlSource of a calculated control
>
> You should not put data directly into tables anyway.
>
> Also, the equation you are using won't work properly if the person was
> born in December and the current month is July because Access will just
> take the difference of the years.
>
> This was posted by Ricky Hicks:
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> To get the current age .. use:
>
> DateDiff("yyyy", [DOBField], Date()) +
> (Date() < DateSerial(Year(Date()), Month([DOBField]), Day([DOBField])))
>
> "DOBField" should be the name of the field that contains the Date of
> Birth value ...
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> Warm Regards,
> Crystal
> *
> (: have an awesome day
> *
> MVP Access
>
>
>
> Berek wrote:
> > I trying to determine the age of a person and I was using this command in the
> > default value:
> >
> > DateDiff("yyyy",[birth_date],Date())
> >
> > and when i try to save the table it says
> >
> > "The database engine does not recognize either the field 'birth_date' in a
> > validation expression, or the default value in the table 'general'
> >
> > I believe it is the latter situation, but not sure how to fix it
> >
> > Thanks

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Birthdates to Calendar SKSmith Microsoft Outlook Calendar 1 18th Feb 2010 04:30 PM
Calculating Birthdates =?Utf-8?B?bXlsb3Zl?= Microsoft Access 5 13th Sep 2005 12:34 PM
Calculating Ages from Birthdates =?Utf-8?B?S2VuZGxl?= Microsoft Excel Misc 2 6th Jan 2005 07:16 PM
Sort by birthdates =?Utf-8?B?YmVzdGl2bw==?= Microsoft Excel Misc 2 10th Nov 2004 07:05 PM
birthdates BJ Microsoft Outlook Contacts 1 8th Oct 2003 11:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 PM.