472,122 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

Highlight the current record?


I have a form which I need to highlight the controls in the current record.

How to do?

Feb 14 '07 #1
9 13927
12,516 Expert Mod 8TB
What do you mean highlight the controls?

You could just change the background color of the controls. Are you talking about a continuous form? If you are then you'd want to change the background color of the controls in the form's On Current event.
Feb 14 '07 #2
Thanks for your respond,

But I want to avoid writing much in events.
there are many controls in my forms and it's difficult to write for all of them to change the backcolor and font color separately.
Is there easier way to change the backcolor and fontcolor in the current record?
for example by conditionnal formatting?

Feb 14 '07 #3
12,516 Expert Mod 8TB
What do you mean by current record? Is this a continuous form?
I'm unsure as to when and how you want to "highlight" these controls so I can say if conditional formatting is the solution you're looking for.
Feb 14 '07 #4

I have a Continuous Form and I need highlight the current record because:

when user clicked in any record, all the controls in that record should have different backcolor and font color to look easier.

So, If there is any easy way, How should I do?

Feb 14 '07 #5
12,516 Expert Mod 8TB
I don't know of a way to do what you want. Maybe someone else will know how to do this.
Feb 14 '07 #6
14,534 Expert Mod 8TB
I don't know of a way to do what you want. Maybe someone else will know how to do this.
The problem is you can conditional format a field but not an entire record. If you try to do it in code then all the records would change.

Feb 15 '07 #7
159 Expert 100+
Highlighting the current record on a continuos form can be tricky since conditional formatting has no built in conventions for recognizing when a record is selected and as Mary stated using the oncurrent event changes the formating of all records not just the current one (if that makes sense).
But, If your absolutley determined to highlight the current record you can do so by using this workaround method.

First, your form’s record source must contain a unique identifier for the records such as a primary key (if it doesn’t it probably should for general principals) this does not need to have a control on the form, as long as its present in the recordsource.

Second, you will need to create a module and declare a global variable as well as a function to pass that variable back to Access. See this discussion http://www.thescripts.com/forum/thread558852.html

Once you have your module complete your ready to setup your oncurrent event and conditional formatting.

In the forms on current event enter this code

Expand|Select|Wrap|Line Numbers
  2. Private Sub Form_Current()
  4. CurRec = Me.[myPrimaryID]     ‘CurRec is the global variable declared in your module
  5. DoCmd.Requery "Text1"
  7. End Sub
In your requery command you need only requery one control even if the conditional formatting is on several controls, they all update with a single requery, also don’t requery the whole form because that restarts the form’s on current event and the form hangs.

Then in the controls’ conditional formatting enter the expression:
Expand|Select|Wrap|Line Numbers
  1. [myPrimaryID]=Glovar("CurRec")
You can use conditional formatting on all of your controls or create an unbound textbox behind the forms to act as a background and just format that. If you do the latter you’ll want to put a gotocontrol command in the unbound text boxes on enter event so if the user clicks on it they are automatically sent to another control.

Hope this helps,
Feb 15 '07 #8
Thanks a lot But,

I could't understand in your recommend link which module should I use?

Can you post here the module which I have to create too?

I think it's the best way which I found in different site.

Thanks again
Feb 16 '07 #9
159 Expert 100+
this is what you want in your module

Expand|Select|Wrap|Line Numbers
  1. Global RecNo as variant
  3. Public Function GloVar(ByVal VarName) As Variant
  5. Select Case VarName
  7. Case "RecNo"
  8. GloVar = RecNo
  10. End Select
  11. End Function
Feb 16 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Tony | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.