Highlight Current Record (1 Viewer)

mohammadagul

PrinceAtif
Local time
Today, 08:35
Joined
Mar 14, 2004
Messages
298
How to Highlight elected Record ?

Hello Everyone,
I would like to know a way to highlight the current record in a continuous form. I have tried many ways as shown in microsoft but everytime there are error. Is there any simple and easy way to just highlight the current record.

thanks
Muhammad Atif
 

doran_doran

Registered User.
Local time
Yesterday, 23:35
Joined
Aug 15, 2002
Messages
349
set focus....

have you tried set focus. you may need to tell the system to look for current record by max autoid or max date and then set focus to that record. do a seach on the forum there are tons of set focus sample.

good luck

dianna goldsberg
 

ghudson

Registered User.
Local time
Today, 00:35
Joined
Jun 8, 2002
Messages
6,195
Access 97 will not allow that without a whole lot of coding. Access 2000/2002/2003 will let you use conditional formatting which I believe will do what you want for a continuous form.
 

missinglinq

AWF VIP
Local time
Today, 00:35
Joined
Jun 20, 2003
Messages
6,423
I've seen this question asked beaucoup times here and on other forums and have never seen a workable answer. On non-continuous forms, you can change things based on moving from one record to another by using the FORM'S "On Current" property. For instance, you can run a function and find out and post which record in the database is currently being displayed. The problem, as I understand it, is that on continuous forms the entire form is always "Current".

Maybe someone out there has a workaround, but as I've said, I've seen this exact problem posed before without an answer being found.

The Missinglinq
 

DALeffler

Registered Perpetrator
Local time
Yesterday, 22:35
Joined
Dec 5, 2000
Messages
263
i've got one working (sort of like what you need to do).

It's dirty, very limited in scope, and pretty complex. The only reason I spent days coding that thing is because I absolutely had to have it.

What you basically have to do is design a subform that you can place on your main form as many times as you'll have records in the table you're trying to highlight.

If your table has 200 records, your main form will have 200 subform controls on it (and I didn't even try to do this programatically; I manually added 200 subform controls - this is not as bad as you'd think - to the unbound main form).

Each subform will have one record from your table. It's fairly straight forward to click on a record (subform) on the main control and manipulate the subforms backcolor to "highlight" that "record".

Now a user wants to click on another "record" of the main form. Your code has to un-highlight the previous record (subform control) and highlight the new curent record. And that gets, well, involved...

And after all that, I found that my systems' response time bogs down considerably after about 100 subform controls. I was waiting 4-5 seconds for screen updates on a query recordset with less than 200 records. A big problem is that even though your recordset might not have 200 records in it, your form still has 200 subform controls on it and your code has to take that into account every time a user changes to a new record.

Still interested?

Doug.
 
Last edited:

Oldsoftboss

AWF VIP
Local time
Today, 14:35
Joined
Oct 28, 2001
Messages
2,499
Hope the att will help.

Dave
 

Attachments

  • Changing the Color of the Current Record in a Continuous Form.zip
    5.5 KB · Views: 4,251

DALeffler

Registered Perpetrator
Local time
Yesterday, 22:35
Joined
Dec 5, 2000
Messages
263
Oldsoftboss said:
Hope the att will help.

Dave

My sweet goodness did it help!!

Thank you, Thank you!!

I just got rid of 99.9% of the code I was using to "conditional format" records in a subform I spent days coding to run.... Wow!

Take my previous post and forget it - it's not even close....

The one problem I did have...

The order in which to create controls on the form (the control for highlighting vs the control for the value to be highlighted) made a difference.

The control that is used to do the highlighting (source:=IIf([cellwatch]=True,"ÛÛÛÛÛÛÛÛÛÛ",Null)), had to be created first. THEN create the bound control on the form.

This was necessary (for me, anyway) to get the highlighting control "behind" the bound control. Otherwise the bound control text was "blocked" by the highlighting control.

Once I found that out, the highlighting control became my "conditional formatting" condition, as in: =IIf([cellwatch]=True,"ÛÛÛÛÛÛÛÛÛÛ",Null), letting me highlight records where [CellWatch] was checked - without using the code for specifying the current record! I thought that'd be tougher than highlighting the current record!

Nope. You only need the code if you want to highlight the current record.

Oldsoftboss - Sharp as a tack...

Doug.
 
Last edited:

Oldsoftboss

AWF VIP
Local time
Today, 14:35
Joined
Oct 28, 2001
Messages
2,499
I cant take all the credit. I have a folder in my PC where I keep access examples. This is one I copied from here some time ago.

Dave
 

Giles

Registered User.
Local time
Today, 05:35
Joined
Nov 13, 2003
Messages
12
DALeffler said:
The one problem I did have...

The order in which to create controls on the form (the control for highlighting vs the control for the value to be highlighted) made a difference.

I'm trying the code that Oldsoftboss posted (thanks very much, Oldsoftboss - it may solve a huge problem) but I have a snag that sounds similar to yours. I've tried creating the form fields after the highlighting control, and it does make a difference, but I think there's something else that's not quite right. In fact there are two issues which may be related:

- When the form is opened, the highlighting control (CtrlBack in the Northwind example) shows up as opaque on the selected record with the text #Name? in the highlight colour at its top left corner. On the other records the highlighting control is transparent but the #Name? is still there in the highlighting colour.

- The instructions in the document say to size the highlighting control to cover "the entire area where you would like the background to be". I've assumed that this means the control should cover all the text boxes and similar controls on the form, and since these are of different sizes and placed at various locations on the form, the highlighting control also covers a fair amount of empty space. When, having created the controls in the order you suggest, I click directly on a text box, the highlighting control remains transparent. But when, as a user might well do, I click on the space between text boxes the highlighting control becomes opaque.

I wondered if you (or anyone else) might have any ideas? For what it's worth I'm using Access 2002, in which the help files are completely silent on the subject of IIf statements (could this be the problem?)
 

DALeffler

Registered Perpetrator
Local time
Yesterday, 22:35
Joined
Dec 5, 2000
Messages
263
The #Name error might mean that a field in the Iif statement is causing Access some problems. Can you post it?

As far as someone clicking on the highlight field and making the field opaque, try setting the Enabled property for that highlighting field to No.

Nah... setting Enabled to No won't work: just grays it out. I think you may be stuck with creating highlight fields that don't extend past the limits of the control on the form you're trying to highlight. Sorry 'bout that.

Danggit!! Lock AND disable the field...

hth,
 
Last edited:

Giles

Registered User.
Local time
Today, 05:35
Joined
Nov 13, 2003
Messages
12
DALeffler said:
The #Name error might mean that a field in the Iif statement is causing Access some problems. Can you post it?

I thought I'd copied the statement faithfully but, prodded by your comment, I went back and realised I hadn't included the original = sign. Now that I have, it works. Doh! (Well, in my defence I can at least plead mitigation due to the absence of any guidance on using IIf in the help files.)

Nah... setting Enabled to No won't work: just grays it out. I think you may be stuck with creating highlight fields that don't extend past the limits of the control on the form you're trying to highlight. Sorry 'bout that.

Danggit!! Lock AND disable the field...

Aha! Yes! In the meantime I'd also come up with the idea of having separate highlight fields for each control but I was getting a bizarre effect: clicking anywhere on the space between controls caused the highlighting on control 1 to become opaque; investigation showed that Access was recording a click on control 1's highlight field even though the cursor was nowhere near it. I still can't figure out what the heck was going on, but your lock & disable approach fixes this completely.

Doug, many thanks for your help. I now have a database that works and looks reasonably professional (at least, I like to think so). So, on to the next step!

Giles.
 

DALeffler

Registered Perpetrator
Local time
Yesterday, 22:35
Joined
Dec 5, 2000
Messages
263
There is one other minor problem I've found when using the "=IIf([cellwatch]=True,"ÛÛÛÛÛÛÛÛÛÛ",Null))" record source for highlighting records other than the current record (I don't know if the same problem will exist for the current record highlight also...).

I'm using a subform to display the record set where I would like the highlights to appear, and that record set can sometimes be up to 180 records or so.

If a user uses the scroll bar (click & drag) and scrolls past the displayed set of records (I can only show 15, 16 records tops in my current subform), the highlights do not appear until after the user releases the mouse button. That can confuse a user.

So far this really hasn't been an issue but I don't particulary care for it that way and may end up writing my own scroll cmd button arrows (and disabling the subforms' scroll bars) if it starts to bug me enough (and I'm currently kinda' bugged by it...).

Just a heads up...
 

ChrisO

Registered User.
Local time
Today, 14:35
Joined
Apr 30, 2003
Messages
3,202
G’day all.

Don’t know if the attached demo will help… but it might.

Regards,
Chris.
 

Attachments

  • Continuous_Form_Check_Boxes_97_V5.zip
    28.5 KB · Views: 1,028

Giles

Registered User.
Local time
Today, 05:35
Joined
Nov 13, 2003
Messages
12
DALeffler said:
If a user uses the scroll bar (click & drag) and scrolls past the displayed set of records (I can only show 15, 16 records tops in my current subform), the highlights do not appear until after the user releases the mouse button. That can confuse a user.

Thanks for the warning. As things stand in my database I'm highlighting only the current record and not anything else, and the highlighting seems to work OK when the record appears from off the screen using the scroll bar. I'll bear it in mind,though, if I get to feeling adventurous when the database is nearing completion!

Giles.
 
D

dipstick

Guest
easy solution with conditional formatting

Spent ages hunting for an answer to this problem and eventually worked it out for access 2002 at least. This solution lets you have the current row highlighted in one colour and the control with focus in another. The key is the syntax used in the expression which must be "Forms!formname" as "me" doesnt work, and you must use a textbox as it wont work with form variables. The text box does not have to be bound to the database.

Setup your continuous form which must include one field that is a unique index, but this can be invisible.

Add a textbox to the form header (not in the detail part of the form)called "txtactiverecord".

In the "on current" event enter the code "txtactiverecord=uniqueindex" where "uniqueindex" is the name of you unique index field. If your index field is not text then you will have to use a function to convert it to a text value. for example if it is a number you could use "txtactiverecord=str$(uniqueindex)"

select every field on the continuous form and use conditional formating to set the colour if the field has the focus. I usually use dark blue background and white text.

Now do the same but add a second condition. This time pick "condition is" and type in "forms![form name].txtactiverecord=[mytableuniqueindex]".

Substitute the name of your form where it says "[formname]" and don't type the quotes.

Substitute the name of your index field where it says "[mytableuniqueindex]" and don't type the quotes.

Now choose the colour you want the rest of the highlighted row to be. I usually use yellow background and black text for this.
 

JamminUK

New member
Local time
Yesterday, 21:35
Joined
May 8, 2008
Messages
2
Thank you Dipstick, i've been looking for a solution to this problem for a while now and yours is by far the simplist and most effective, didn't think all that complex coding was needed and you proved it. Just shows you there are many ways to complete the same task and some are better then others! No offence to others! :)
 

JamminUK

New member
Local time
Yesterday, 21:35
Joined
May 8, 2008
Messages
2
However it doesn't appear to work for subforms? Any ideas?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:35
Joined
Sep 12, 2006
Messages
15,692
hey DA

not quite the same issue, but similar - i have a quote form - the client wanted a fixed quote form with 50 items in 2 cols of 25. - Originally I popluated this with 50 sets of data boxes, and filled them by loading an array and populating the boxes.

This was too lsow, so subsequently I did it be making the form multi-column. Inordinately quicker, and much more satisfactory.

The trouble with continuous forms is that you are only defining a single template for the form, so there is no (easy?) way of achieving different formats. MS obvioulsy realised this when they came up with conditional formatting, but it looks like this is a bolt-on workround, and not native to Access - which probably explains why there is only 3 conditional options.
 

Users who are viewing this thread

Top Bottom