INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Access Howto:

How to highlight the selected record in a continuous form by Frink
Posted: 17 Apr 02 (Edited 14 Apr 08)

Hallo,

This FAQ explains how to highlight the selected record of a continuous form by changing the background colour of the current record. This has only been tested in Access '97. In later versions of access you can use Conditional Formatting to acieve this highlighting.

Firstly I'll assume your form is based on a table with a primary key of lngId.

Create a text field control txtBackground to the size of your whole record, and send it to the back of the form.
Make the font WebDings and the forecolor the 'selected' colour you want. Make the background colour the 'unselected' colour.

Make the background colour of all your controls in the record as the selected colour, but make them all transparent.

Create a new text control called txtCurrentRecord and put it in the form header or footer. You can make this invisible once you've checked that it works.
In the OnCurrent Event procedure, put:

CODE

Me!txtCurrentRecord = Me!lngId

Set the Control Source of txtBackground:

CODE

=IIf([lngId]=[txtCurrentRecord],String$(10,"g"),"")

This field will be empty unless the record you're on is the current record, in which case it would be a string of 10 WebDings g characters, which happen to be a solid block.

If the coloured bar is not tall enough then increase the font size in txtBackground.
If the coloured bar is too narrow then increase the '10' in the Control Source.

Hope that makes your forms prettier,

- Frink

Note: SturdyErde has (rightly) pointed out that this will not work for new records where lngId is an autonumber as these are not populated until the record is saved.
He suggests adding an Or IsNull statement to the IIf statement. I no longer have Access '97 so am unable to test this

Back to Microsoft: Access Other topics FAQ Index
Back to Microsoft: Access Other topics Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close