![]() |
Automatically calculate age from birthdate
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 |
Automatically calculate age from birthdate
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" wrote in message ... 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 |
Automatically calculate age from birthdate
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" wrote in message ... 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" wrote in message ... 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 |
All times are GMT +1. The time now is 08:12 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com