Help!

Automatically calculate age from birthdate

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Forms RSS
Next:  Finding Cell address by value  
Author Message
Fred Boer
External


Since: Jun 29, 2009
Posts: 3



PostPosted: Mon Jun 29, 2009 8:15 pm    Post subject: Automatically calculate age from birthdate
Archived from groups: microsoft>public>outlook>program_forms (more info?)

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
Back to top
Fred Boer
External


Since: Jun 29, 2009
Posts: 3



PostPosted: Mon Jun 29, 2009 8:59 pm    Post subject: Re: Automatically calculate age from birthdate [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <fredboer.TakeThisOut@NOyahooSPAM.com> wrote in message
news:OB$sQfR%23JHA.4560@TK2MSFTNGP05.phx.gbl...

> 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
Back to top
Fred Boer
External


Since: Jun 29, 2009
Posts: 3



PostPosted: Tue Jun 30, 2009 8:01 am    Post subject: Re: Automatically calculate age from birthdate [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <fredboer RemoveThis @NOyahooSPAM.com> wrote in message
news:uYSaa6R%23JHA.4692@TK2MSFTNGP02.phx.gbl...
>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" <fredboer RemoveThis @NOyahooSPAM.com> wrote in message
> news:OB$sQfR%23JHA.4560@TK2MSFTNGP05.phx.gbl...
>
>> 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
>>
>>
>>
>
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Forms All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum