Avatar of GenesisTech
GenesisTech
 asked on

MS Access Continuous Forms Highlight Record with Focus ONLY

In MS Access I have a Continuous Form with 8 fields on it. The last field gets updated and the other fields help you know what  you are updating.

Data entry people go down the list and enter data in the last field. The challenge is that they make mistakes because it is difficult to tell which Row they are on.

I would like for the entire row to turn RED when the last field is being updated (has focus) while the rest of the rows stay light gray. That would make it REALLY easy to know which row you are working on.

Any ideas?
Microsoft AccessVBA

Avatar of undefined
Last Comment
crystal (strive4peace) - Microsoft MVP, Access

8/22/2022 - Mon
Jim Dettman (EE MVE)

Attached is the "old school" way of doing it.

New way is to use conditional formatting on a control (same technique as the sample DB, use a control and set it behind all the other controls, apply conditional formatting as needed, then make all your controls backgrounds transparent).

Holler if you need more.

Jim.
ContinuousFormColors.zip
ASKER CERTIFIED SOLUTION
crystal (strive4peace) - Microsoft MVP, Access

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
GenesisTech

ASKER
Jim,

I prefer to do this using conditional formatting but am not exactly sure how to set it up.

So, I put a text box in the background the full length of all fields, so that it covers the whole row, and I call it txtBGColor.
I assume that I would need to apply the Conditonal Formatting to txtBGColor but what expression would I use? Would I use an expression that evaluates the value of another field? I don't think that will work.
Nick67

Sure.
What version of Access?

In Access 2003+ I get that going as follows:
In the detail section I add a control, a checkbox call chkCurrent
That checkbox has a ControlSource of a function called IAmCurrent()

IAmCurrent() is a private function as follows
Private Function IAmCurrent()
IAmCurrent = (Me.JobID = Nz(TheJobID, 0))
End Function

Open in new window

JobID is the primary key of the recordset on the form
TheJobID is a Public variable in a code module
Public TheJobID As Long

The Current event of the form is as follows
Private Sub Form_Current()
TheJobID = Me.JobID
Me.chkCurrent.Requery
End Sub

Open in new window


The next effect is that the Current Event makes chCurrent true for just the current record.

And all the controls on the detail section have conditional formatting as follows
Expression IS   [chkcurrent]=True  Background color Yellow

And so, clicking into a different record makes all its controls background yellow, and everything else stays the default white.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
GenesisTech

ASKER
Crystal,

I think you just answered the question. Let me implement and test and I will respond shortly.

Thanks!
GenesisTech

ASKER
Crystal,

What is this: " add field to RecordSource:
HighlightBox: Space(50) 'or however many characters are right for your form"

Other than that, I have set it up and it is not working. I think that the color is not showing through because the fields are gray. How do I "turn off" alternate row formatting?
GenesisTech

ASKER
Beautiful. It is working now.

I still do not understand what this is for:
add field to RecordSource:
HighlightBox: Space(50) 'or however many characters are right for your form"

I did NOT add a field to my record source and it is working great.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Nick67

You do it like this
Current.mdb
GenesisTech

ASKER
Any idea why the textbox I am updating goes gray when it gets the focus? All textboxes are set to background=transparent. But, when I click in it to update it, it is no longer transparent and shows a light gray background.
SOLUTION
crystal (strive4peace) - Microsoft MVP, Access

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Nick67

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
crystal (strive4peace) - Microsoft MVP, Access

thanks, Nick ~ I use Back Color and Transparent almost all the time ... so I phrased it the way I use it ;) ~ Interesting to read the definition though.

Genesis, the padding comment should have been right after > "HighlightBox: Space(50)".  I tried to edit my post but Nick already posted too so I couldn't ~
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Nick67

It clearly works as described, but the Help has always been silent about the .GotFocus element of it.
https://msdn.microsoft.com/EN-US/library/office/ff196119.aspx

Syntax
--------------------------------------------------------------------------------
expression .BackColor
expression A variable that represents a TextBox object.

Remarks
--------------------------------------------------------------------------------
The BackColor property contains a numeric expression that corresponds to the color used to fill a control's or section's interior.

You can set the default for this property by using a control's default control style or the DefaultControl property in Visual Basic.

To use the BackColor property, the BackStyle property, if available, must be set to Normal.
crystal (strive4peace) - Microsoft MVP, Access

glad you've got it working

> "How do I "turn off" alternate row formatting? "

That is the Alternate Back color property of the section (click on the section divider to easily select the section) and you will find it on the Format tab pf the Property Sheet
GenesisTech

ASKER
Crystal - Thank you for an awesome solution to my problem. Thank you for answering the back color issue as well, though it was a little confusing. So, I gave Nick some points for helping to clarify.

You both were a big help and you saved me so much time. I sincerely thank you!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
crystal (strive4peace) - Microsoft MVP, Access

you're welcome ~ happy to help ... and to collaborate on the best solution.  In my opinion, rarely should all the points go to just one ~ life is about teamwork too.