PC Review


Reply
Thread Tools Rate Thread

Automatically calculate age from birthdate

 
 
Fred Boer
Guest
Posts: n/a
 
      30th Jun 2009

Hi:

I have a textbox which I want to have filled with the contact person's age,
derived from birthdate using a formula. I have a formula, and have created a
working textbox. If I change the birthdate it fills in the textbox.

But...

I have existing birthdate data for contacts. The textbox does not appear to
respond to existing data. Is there a way to force the calculation when I
move from one contact to another (on menu using up/down arrows), or when I
open the form for a contact who has an existing birthdate?

Thanks!
Fred



 
Reply With Quote
 
 
 
 
Fred Boer
Guest
Posts: n/a
 
      30th Jun 2009
I am making some progress. This works:
Item.UserProperties.Find("Age").Value = "Hello"

But this generates a "Type Mismatch" error message:

Item.UserProperties.Find("Age").Value =
IIf([Birthday]<>"None",DateDiff("yyyy",[Birthday],Date())-IIf(DateDiff("d",CDate(Month([Birthday])
& "/" & Day([Birthday]) & "/" & Year(Date())),Date())<0,1,0),"")

Still plugging away...

Thanks!

Fred

Fred Boer" <(E-Mail Removed)> wrote in message
news:OB$sQfR%(E-Mail Removed)...

> Hi:
>
> I have a textbox which I want to have filled with the contact person's
> age, derived from birthdate using a formula. I have a formula, and have
> created a working textbox. If I change the birthdate it fills in the
> textbox.
>
> But...
>
> I have existing birthdate data for contacts. The textbox does not appear
> to respond to existing data. Is there a way to force the calculation when
> I move from one contact to another (on menu using up/down arrows), or when
> I open the form for a contact who has an existing birthdate?
>
> Thanks!
> Fred
>
>
>




-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
 
Reply With Quote
 
Fred Boer
Guest
Posts: n/a
 
      30th Jun 2009

Hello:

I've learned that the problem is with IIF in VBScript (I thnink!).
Found this code (thanks Sue Mosher):

Public Function IIf(blnExpression, vTrueResult, vFalseResult)
If blnExpression Then
IIf = vTrueResult
Else
IIf = vFalseResult
End If
End Function

and now this expression appears to work:

Item.UserProperties.Find("Age").Value =
IIf([Birthday]<>"None",DateDiff("yyyy",[Birthday],Date())-IIf(DateDiff("d",CDate(Month([Birthday])
& "/" & Day([Birthday]) & "/" & Year(Date())),Date())<0,1,0),"")

Thanks,
Fred

"Fred Boer" <(E-Mail Removed)> wrote in message
news:uYSaa6R%(E-Mail Removed)...
>I am making some progress. This works:
> Item.UserProperties.Find("Age").Value = "Hello"
>
> But this generates a "Type Mismatch" error message:
>
> Item.UserProperties.Find("Age").Value =
> IIf([Birthday]<>"None",DateDiff("yyyy",[Birthday],Date())-IIf(DateDiff("d",CDate(Month([Birthday])
> & "/" & Day([Birthday]) & "/" & Year(Date())),Date())<0,1,0),"")
>
> Still plugging away...
>
> Thanks!
>
> Fred
>
> Fred Boer" <(E-Mail Removed)> wrote in message
> news:OB$sQfR%(E-Mail Removed)...
>
>> Hi:
>>
>> I have a textbox which I want to have filled with the contact person's
>> age, derived from birthdate using a formula. I have a formula, and have
>> created a working textbox. If I change the birthdate it fills in the
>> textbox.
>>
>> But...
>>
>> I have existing birthdate data for contacts. The textbox does not appear
>> to respond to existing data. Is there a way to force the calculation when
>> I move from one contact to another (on menu using up/down arrows), or
>> when I open the form for a contact who has an existing birthdate?
>>
>> Thanks!
>> Fred
>>
>>
>>

>
>



 
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
Calculate age category from birthdate =?Utf-8?B?TXMuIEMu?= Microsoft Access Getting Started 4 14th Dec 2006 02:41 PM
How do I calculate an age from a birthdate =?Utf-8?B?UmFuZHkgUmlsZXk=?= Microsoft Access Form Coding 3 2nd Feb 2005 07:18 PM
How do I calculate an age from a birthdate in excel? =?Utf-8?B?Q0ZlbnRvbg==?= Microsoft Excel Worksheet Functions 1 29th Nov 2004 05:22 PM
How can I calculate age with the birthdate? =?Utf-8?B?TWF0dA==?= Microsoft Access 5 1st Sep 2004 12:58 PM
Calculate Age From Birthdate =?Utf-8?B?U2FuZHk=?= Microsoft Access Queries 3 22nd May 2004 05:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 AM.