Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126

    Question Unanswered: How to highlight current row

    OK, I've done this before but with a head like a sieve I just cannot remember. What I want to achieve is to highlight the selected/current/focused row in a continous form. I seem to remember the trick was to define a text box (or similar) with a different back colour to the environment. Then there some test to 'activate' this box in some way that only happened for the selected row.

    Anyone got any ideas?

  2. #2
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251
    I'm not sure if that would work....

    but you can try Conditional formating.... when you jump to record change conditinal format of the form to some color when ID is ID of the record you are on... OR have hidden dummy field there and when you jump to record give it some value and have conditional format based on that value....

    i don't have Access2k here, but I can give you sample later today... let me know.



    jiri

  3. #3
    Join Date
    Jan 2003
    Location
    St Louis
    Posts
    14

    Re: How to highlight current row

    Originally posted by Rod
    OK, I've done this before but with a head like a sieve I just cannot remember. What I want to achieve is to highlight the selected/current/focused row in a continous form. I seem to remember the trick was to define a text box (or similar) with a different back colour to the environment. Then there some test to 'activate' this box in some way that only happened for the selected row.

    Anyone got any ideas?

    I had the same problem with a list box ...what worked was
    setting the ItemData to the Row....

    Me.ListBoxNewApp.Requery
    Me.ListBoxNewApp.Value = Me.ListBoxNewApp.ItemData(0)

    Hope that Helps

  4. #4
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    33

    Re: How to highlight current row

    Originally posted by Wlinks
    I had the same problem with a list box ...what worked was
    setting the ItemData to the Row....

    Me.ListBoxNewApp.Requery
    Me.ListBoxNewApp.Value = Me.ListBoxNewApp.ItemData(0)

    Hope that Helps
    Hi,
    I also did it once, but on slower machines the box redraw was ugly.

    Anyway this involves inserting a text box with BACK color transparent and FORE color a color of you highlight. Then you have to enumerate every row of continuous form and add contol (SelTop, as far as I recall) to determine current row. Textbox control source will then be =iif(([rownum]=[currentrow]),"BOX","") - where "BOX" is e.g. appropriate number of chr(219) of "terminal" font - you need to simulate box that covers you record background with text. Text Box has to be the "sent to back".

    Sorry for being too sketchy, if you have problems implementing I can lookup procedure in by apps archive.

    HTH
    Alec

  5. #5
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251
    attached is CONDITIONAL FORMAT sample.... Access2k format


    enjoy


    jiri
    Attached Files Attached Files

  6. #6
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    33
    Thanks for your example playernovis,
    FormatCoditions collection adds very nice functionality, unfortunately avaliable only from Aceess2k

  7. #7
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Thanks everyone for your help.

    The solution that I could not remember but have since recalled relies on fore color (not back color). The trick is to define an unbound text box placed behind all other controls with a data source of =iif(condition,”gggggggg”,null). The fill color of the text box is either transparent or set to match the surroundings; the fore color is set to the desired highlight color. The font is set to Webdings where the lower case ‘g’ equates to a block character. (Other fonts also contain a block character but I find this combination the easiest to use.) The number of ‘g’s in the string and the font size have to be adjusted until the result cover the area desired for the highlight. Finally the condition is one that is true only for the current row. I find something like [UniqueId]=Me!UniqueId works well, if necessary including UniqueId as a hidden control in the row.

    The advantages of the foregoing solution are that it can be applied to versions earlier than Access 2000 and can be specified entirely from the form design window (i.e. it does not need event handling and VBA).
    Having said all this I was intrigued by the solution using conditional formatting – something that is new to Access 2000 and something I have never used before. Thanks playernovis for taking the time and trouble to post the actual code. Perhaps you could explain why it is necessary to delete and reset the formatting for every ‘on current’ event. Why can’t the conditional formatting simply carry over from row to row? I know it doesn’t work because I tried but I fail to understand why. (Also the example given in the Help does not work for me as written.) I like this solution since you do not have to fiddle with the number of characters and font size but can simply drag the text box to the desired size.

    Also as a footnote may I warn everyone that SelTop is badly behaved when you navigate using (clicking on) record selectors. In one direction SelTop returns the number of the PREVIOUS row and not the current row. Everything's OK if you allow a control within the row to have the focus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •