How to change the color of the selected line in a subform


I want to change the color of the selected line in a subform.
Now i have set all fields backcolor to Transparent.
I have made a textbox "TBox" in size the same as all the other controls and it is set to "send to back".
When i select a line and i execute the code and i set a breakpoint just before "Me!TBox.Visible = True" and then use F8 then everything works fine.
When i execute the code in a normal way the color don't change.
In the on_current event i have :
Me!TBox.Visible = False
and in the on_click event of a certain field i have at the end of a code :
Me!TBox.Visible = True
Who is Participating?
mbizupConnect With a Mentor Commented:
Are you trying to set a background color for the currently selected line in a continuous form?

Instead of setting the visible property (this won't work the way you want with a continuous form),  try this:

- Add a hidden textbox called txtHold to your form (Visible = False, always).  It will be used to hold the ID of the currently selected record.

- In the current event of your form, add the following:
   Me.txtHold = Me.YourIDField

Open in new window

Take out the code which toggles the visible property of the large background textbox and instead use Conditional Formatting.

- Right-click your background textbox in design view and click Conditional Formatting...

- Create a new rule, and select "Expression Is" from the drop-down list

- Enter this expression into the textbox provided for the conditional formatting expression:
        [txtHold] = [YourIDField]

Open in new window

  (YourIDField should be the name of your primary key field as it appears in the underlying table.  This expression is criteria for determining the 'currently selected row')

-  Select the background color you want for your textbox when that condition is met.
Rey Obrero (Capricorn1)Commented:
try adding this line

Me.TBox.Visible = True
me.repaint   'add this line
sonmicAuthor Commented:
Tx, but the result is the same.
All Courses

From novice to tech pro — start learning today.