wenzelj Posted February 21, 2005 Share Posted February 21, 2005 Am trying to use the text color function to Display Red when a person is under 18 yrs old. Having some questions about setting up the calc to achieve this. Help would be appreciated. Thanks Link to comment Share on other sites More sharing options...
wenzelj Posted February 21, 2005 Author Share Posted February 21, 2005 The fields I have set are DOB(date) and then Age is a calc. I want the Age field to turn red when the person is a minor <18 yrs old. Hope this additional info helps. Link to comment Share on other sites More sharing options...
RalphL Posted February 21, 2005 Share Posted February 21, 2005 Try this text calculation: Let ( [ C = Get ( CurrentDate ) ; yC = Year ( C ) ; dayC = DayOfYear ( C ) ; B = BirthDay ; yB = Year ( B ) ; dayB = DayOfYear ( B ) ; Num_Years = yC - yB -(dayC < dayB) ] ; Case ( Num_Years < 18 ; TextColor ( Num_Years ; RGB ( 255 ; 0 ; 0 ) ) ; Num_Years ) ) Link to comment Share on other sites More sharing options...
wenzelj Posted February 22, 2005 Author Share Posted February 22, 2005 A problem that I am running into is that the Age is already a calc. When I try to add the Text Color function to it the Result is a "?" Am I going to need two seperate fields or is there a way to combine the two calcs? Help would be appreciated. Thanks. Link to comment Share on other sites More sharing options...
-Queue- Posted February 22, 2005 Share Posted February 22, 2005 Make sure it's a text field. TextColor doesn't work with non-text fields. You may want to use two fields specifically for this reason. Also, Ralph's calc looks a little off. You want to compare the day of year for the birthday based on the current year. So dayB should be equal to DayOfYear(Date( Month(:; Day(:; yC )) IMO. Link to comment Share on other sites More sharing options...
comment Posted February 22, 2005 Share Posted February 22, 2005 I'd thought by now the "age in years" question would be settled. Using DayOfYear() is problematic on account of leap years. Link to comment Share on other sites More sharing options...
RalphL Posted February 22, 2005 Share Posted February 22, 2005 I knew I didn't like that calculation. It is from Using FileMaker 7. It may be the only thing in the book that is questionable. Link to comment Share on other sites More sharing options...
-Queue- Posted February 22, 2005 Share Posted February 22, 2005 You're right, of course. It should be (C < Date( Month(:; Day(:; yC )). Ralph confused me because I haven't dealt with age calcs in a while. Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 6603 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now