Jump to content

Recommended Posts

Posted

I need to change the color of a text box depending on the department chosen.

 

 

I have: Cardiology is Red and Primary Care is Teal.

 

 

I found the below code on this forum and it worked for the first page: However, there are two boxes that need the color changed on front and back pages. How can I link those two boxes to always change to the same color?

 

var myFrame = FindTextFrame("MyFrameName"); // or FindGraphicFrame myFrame.fillColorName = "Red"; // or: myFrame.fillColorName = Field("ColorName"); //optionally: myFrame.fillColorPercent = 50;

Posted
However, there are two boxes that need the color changed on front and back pages. How can I link those two boxes to always change to the same color?

The simplest way is to just name both frames (with two different names), and call FindTextFrame and set the fillColorName property twice, once for each named frame. Something like this:

var colorName = Field("Speciality") == "Cardiology" ? "Red" : "Teal";
FindTextFrame("FrontFrame").fillColorName = colorName;
FindTextFrame("BackFrame").fillColorName = colorName;

 

If you want to get more complicated, there are other things you can do. You could define a named color with a custom name, apply that color as the fill in each frame, and change the RGB or CMYK values for that color in OnRecordStart; that's most useful if the color values are coming from the data. You could also use a table cell with a fill color. You could even do something like create a one-pixel graphic with CreateImageFromData, put that in a graphic frame behind your text, and set it to Fill. Lots of ways to skin this cat, but just naming each frame and setting the fill color is the easiest.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...