Share via

Highlight current record on continious form

Anonymous
2011-10-02T02:00:26+00:00

Hi,

I have a conitnious form with a text box in the header that I use for searching.  As one types in the text box the record indicator on the right edge of the form scrolls to the matching record (or the best match).  I would like the matching record to be better highlighted than just the record indicator.  Is there a way to highlight the current record or a field within the current record?

Thanks,

Phil

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-10-02T07:20:09+00:00

Hi

In Access 2007/10 you have this facility build in but not in 2003, so you need to do it yourself.

There are "lots" of ways to do this.

A really simple idea is to the Conditional Formatting.

You need to have unique control content somewhere in each record for this to work - most people would just add the primary field to the form (set it as hidden if you want).

1 Add a new text box to the form's header (not the details section) - call it txtActive

2 In the form's OnCurrent event (in code) add this

me.txtActive = me.IDfield

(of course change IDfield to the name of your primary field)

This is where your personal requirement comes in - this is up to you. Some people will add another text box and put it behind all the other fields and spread out across the form - but for an example do this so you can see how it works.

3 Select a control in the form details section - any control will do - in the Conditional Format option box add a condition like this

[txtActive] = [IDfield]

set the background colour as Yellow (again change IDfield to the real name of the primary control). You can do this for just one control or add the same formatting to all controls or just one big control that is behind all the others, etc, etc

Hope this helps

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2011-10-03T06:22:47+00:00

I assume you have a field in your table (autonumber format) called   MyID  If you haven’t then add one before you start.

I assume you have a form based on your table which is Continuous Format

I assume you are using MS Access 2003

1      Open the form in design view

2      If there is no Form Header then click the View tab at the top of the screen and select Form Header/Footer

3      Add a new Text Box to the Header section.

4      Right Click the next Text Box and select Properties from the option box

5      Select the top row of the column called Other (which is the Name row) and change the name to txtActive

6      Still in design view, select the form -  do this by clicking the grey area outside the details section.  To check that you have done this – in the properties box / data column / record source   you should see the name of the “table” not a table field.

7      In the properties box select the Event column

8      Select the OnCurrent row

9      Select the build option -  that the 3 … (full stops)

10   Select Code Builder from the option box

11   You will see this

Private Sub Form_Current()

End Sub

12   In between these 2 lines of code add this  Me.txtActive = Me.MyID

13   Your code should now look like this

Private Sub Form_Current()

Me.txtActive = Me.MyID

End Sub

14   Click the Save icon at the top of the screen then the Red Close button – to return the form design

15   Drag the bottom of the Details section down – you now have a space underneath all the other controls.

16   Add a new Text Box – call it  txtBackGround

17   Select the Details section of your form – do this by clicking the line at the top of the section (it has the word Detail in it).  The line will go Black

18   In the properties box go to the Format Column and copy the Background colour – a method to do this is to select the number then press Control X  and then Control V.

19   Select txtBackGround

20   In the Format Column paste the number into the Background color row – so that the background of txtBackGround and the details section are now the same.

21   Still in the Format Column set the Border Style to Transparent

22   Still txtBackGround selected click the Format Tab (at the top of the screen) and select Conditional Formatting

23   Change Condition1 to   “Expression Is”

24   Add this into the box  [txtActive] = [MyID]

25   Change the Fill/Back Colour to Yellow (or whatever you want)

26   Click OK

27   Still with txtBackGround selected  click the Format icon (at the top of the screen) and select Send To Back

28   In the properties box (with txtBackGround still selected) in the Format Coloum set the Left row to 0cm

29   Also set the Top row to 0cm.

30   Using your mouse, stretch bottom and right hand edge of txtBackground so if complete fills the area behind all the other controls.

31   Now (as you changed the details height earlier) reset txtBackground height and then reset the Details section height – so it looks OK.  Don’t forget that (as txtBakGround needs to fill the entire details section) you should move the bottom of the details section up until it touches the bottom of txtBackground

32   Select txtActive in the header section.

33   In the Format Column of the properties box select the Visible row and select No.

34   Save

35   Go to Form View and see if this is what you want.

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Anonymous
2011-10-02T17:15:41+00:00

This is as your control is not called Description which is why all other records are calling the condidtional formating and not the one you want

 - it may be bound to a table field called Description but the control has a different name.

Open the form in design view

Right click the control (the text box) and look in the top row of the Other colomn and it "change the name" to  txtDescription

Now change the form's OnCurrent event to

me.txtActive = me.txtDescription

now change the control Condidtional Formating to

Expression Is   [txtActive] = [txtDescription]

Note that table field bound to your form control called txtDescription  MUST be unique for this work - best bet would be to use an AutoNumber field or something else that referes to that specifc record

Was this answer helpful?

0 comments No comments

11 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-10-02T18:02:12+00:00

    me.txtActive = me.txtDescription

    Actually it's the value of the primary key (or any candidate key) you need to assign to the txtActive control, Wayne.  A non-key column could have the same value in more than one row, in which case they'd all be highlighted with the above, not just the current row.  So if the key is named MyID, the code in the form's Current event procedure would be:

    Me.[txtActive]=Me.[MyID]

    and the conditional formatting expression for the control bound to the Description column (the control's name is irrelevant) would be:

    [txtActive]=[MyID]

    with the colour being set to red if this condition is met.

    The txtActive control can be anywhere in the form, not necessarily the header.  Its Visible property should be set to False to hide it.

    PS:  you pretty much said this yourself in your final paragraph.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-10-02T15:34:54+00:00

    Hi,

    Thanks for your response.  I'm close but not there.  I have a field called Description that I want to be red for the current record.  I added the code but the Description field is red for all the records except the current record.  The current record is black.  It's just reverse from what I want.

    What am I missing?

    Thanks,

    Phil

    Was this answer helpful?

    0 comments No comments