Format a subform text box based on main form text box

bpritchert

New member
Local time
Today, 11:00
Joined
Mar 17, 2011
Messages
4
I have a text box on the main form that displays ip addresses. I have another text box in the subform that also displqays ip addresses. I need the text in both boxes to turn red whenever the 2 ip addresses are equal.

I tried to use the 'expression is' option in the subform ip text box, but I don't know what syntax to use to refer to the text box in the main form (Text2) I tried =subform.text2 but that is not correct.

Will this method work and if so what is the correct syntax? If this method will not work is there an alternative?

Thanks.
 
Welcome to the forum.

Bookmark this link for future reference, it has the correct syntax for referring to forms, subforms and their properties and controls, from various relative locations.
 
John,

Thanks for the link but I guess I need more help. Here is the exact situation:

I have form frmPRPageInfo that has 2 text fields in it called text26 and text2
I have a subform called sfrmKeywordInfo that has a field called ip

I want the font of the subform ip field and the main form text2 box to turn red when their values match text26 in the main form.

I tried to put me!text26 in the conditional formatting control of the text2 box but that did not work.

What do I need to enter into the conditional formatting 'expression is' for the text2 box on the main form and the ip field in form 2?

Thanks
 
IN the conditional formatting you will need to use an expression, that looks something like;
Code:
[Forms]![YourMainFormName]![ControlName] = [TextBoxNameToCompare]
Now a quick little trick for determining the correct syntax for a reference to a control on the main form, is to put an unbound text box on your subform, and use the ellipsis (that the button with the three full stops on it) to build a Control Source expression that relates to the field on the main form you are interested in.
 
John,

I feel like an idiot since I can not make this work. Your instructions are clear and I believe I understand them but ...

Here is what I did.
In design view I clicked into the control (text2) that I want to change color when it matches another control (text26) and I entered the following in the conditional formatting expression is box: [Forms]![frmPRPageInfo]![Text2]=[Text26] but nothing happens when text2 and text26 match.

What have I done wrong?
Similarly, In my subform I clicked on my field(IP) and entered [Forms]![frmPRPageInfo]![IP]=[Text26] into the conditional formatting expression is box
 

Users who are viewing this thread

Back
Top Bottom