Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-01-21
3
Medium Priority
?
865 Views
Last Modified: 2014-01-22
Hi,

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
0
Comment
Question by:sonmic
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39797095
try adding this line

Me.TBox.Visible = True
me.repaint   'add this line
0
 

Author Comment

by:sonmic
ID: 39797199
Tx, but the result is the same.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 39797234
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.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question