swf Posted February 16, 2005 Posted February 16, 2005 I have a portal within a layout containing medication name, dose, frequency etc. The final field is whether the medication is active(1) or inactive (0). I would like to write a script that if the active value is 0 (unchecked) then it would change the color of the fields (medication name, dose, frequency etc) in that one record to grey to distinguish it from the active meds. Is this better performed with a calculation field or a script.
spb Posted February 16, 2005 Posted February 16, 2005 It would probably be best done with a calculation field. For simplicity's sake, let's say you have only two fields in your portal, Dose (chosen because it's only four letters!), and the Active/Inactive field, which I'll call Active_Flag. Make a calculation field where the calc is: Case (Active_Flag = 1, "", Dose) If the medication is active, this new field will be Empty, otherwise filled with the contents of Dose (don't forget to make the calc field result: text, assuming Dose is a text field). On your layout make the new field, call it Dose_Display, the same size, font and any other characteristic as the Dose field itself. The one key difference is to alter the text color to be red, or grey if you'd like. Now superimpose this field on top of Dose so it matches exactly. I've found it is comvenient to use the small floating object size pallette, set to pixels for this. I click on Dose, see that it is, say 50 x 13 pixels. I click on Dose_Display and change the pixel dimension to be the same. The field will snap to the exact size. Finally, set the field to not allow entry, so the user doesn't get the "cannot be modified" errort if they accidentally click it. Once your flag is set to inactive, the new field will appear on top of the old Dose field, same text, but in red or grey. The effect is that the field will appear to change color by clicking the Active field. make a simalr field for each of the others you need. Steve Brown
-Queue- Posted February 16, 2005 Posted February 16, 2005 It's much easier in 7. Just make the fields auto-enter calculations with 'do not replace existing value' deselected, equal to TextColor( field; Case( not active; RGB( 190; 190; 190 ) ) )
swf Posted February 17, 2005 Author Posted February 17, 2005 Please clarify somewhat further. Do I need to make a new autoenter calculation field for every field I want to change color (ie medname, dose, route etc.) So do I create a field Mednamecolor=TextColor(Medname; Case( not active; RGB( 190; 190; 190 ) ) ). and then dosecolor=TextColor(dose; Case( not active; RGB( 190; 190; 190 ) ) ) Can't I change them all simultaneously with only 1 calculation. Also help me with not active. The active field is binary 1 for active 0 for inactive. Does "not active" work. Thanks
swf Posted February 17, 2005 Author Posted February 17, 2005 Ignore my last post. Your technique works great on every field except my date fields. I have two date fields. One that automatically enters the date on creation and automatic entry of last modification. I guess textcolor does not work on date field. any ideas?
-Queue- Posted February 17, 2005 Posted February 17, 2005 Yes, this is true. For a date, number, or time field, Steve's suggestion will work for you. Note that you do not need extra fields for the TexColor calc. You simply put the auto-enter calculation into the definition for Dose, Medname, etc., and deselect the 'do not replace existing values' option. Case( field; ... ) is true when field is not equal to zero. Case( not field; ... ) is true when field equals zero. It's an easy way to test number fields, especially when using them as a binary.
Recommended Posts
This topic is 7222 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