Solved

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

Posted on 2014-01-21
3
700 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 119

Expert Comment

by:Rey Obrero
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 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

947 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now