By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Highlight the current record?

P: 8
Hi,

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

How to do?

Fekri
Feb 14 '07 #1
Share this Question
Share on Google+
9 Replies


Rabbit
Expert Mod 10K+
P: 12,316
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

P: 8
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?

Thanks
Fekri
Feb 14 '07 #3

Rabbit
Expert Mod 10K+
P: 12,316
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

P: 8
Yes,

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?

Thanks
Fekri
Feb 14 '07 #5

Rabbit
Expert Mod 10K+
P: 12,316
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

MMcCarthy
Expert Mod 10K+
P: 14,534
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.

Mary
Feb 15 '07 #7

MSeda
Expert 100+
P: 159
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
  1.  
  2. Private Sub Form_Current()
  3.  
  4. CurRec = Me.[myPrimaryID]     ĎCurRec is the global variable declared in your module
  5. DoCmd.Requery "Text1"
  6.  
  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,
Megan
Feb 15 '07 #8

P: 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
Fekri
Feb 16 '07 #9

MSeda
Expert 100+
P: 159
this is what you want in your module

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

Post your reply

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