Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / June 2009

Tip: Looking for answers? Try searching our database.

Automatically calculate age from birthdate

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred Boer - 30 Jun 2009 01:15 GMT
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
Fred Boer - 30 Jun 2009 01:59 GMT
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

> Hi:
>
[quoted text clipped - 12 lines]
> Thanks!
> Fred

-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
Fred Boer - 30 Jun 2009 13:01 GMT
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

>I am making some progress. This works:
> Item.UserProperties.Find("Age").Value = "Hello"
[quoted text clipped - 27 lines]
>> Thanks!
>> Fred
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.