Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Posts
    126

    Unanswered: Highlight control only in current record

    I have a continuous form and to help user's eyes am highlighting the control that is active using the code in GotFocus and LostFocus events:

    Private Sub Highlight()
    On Error Resume Next
    Me.ActiveControl.BackColor = vbYellow
    End Sub

    Private Sub UnHighlight()
    On Error Resume Next
    Me.ActiveControl.BackColor = vbWhite
    End Sub

    The problem to be solved is having only the Control in the Current Record highlighted, not that control in all records visible.
    I tried the following and it doesn't compile:
    Me.CurrentRecord.ActiveControl.BackColor

    Thanks,
    Pete
    PGT

  2. #2
    Join Date
    Jan 2005
    Posts
    146
    Try using conditional formatting, in a continuous form you can't single out the current record.

  3. #3
    Join Date
    Aug 2006
    Posts
    126
    Conditional formatting does work. I was using the other technique from all my other forms. I'd hoped there was a way to save redoing everything in this one.

    OK, next question: I have one button that is in the tab sequence and want to highlight that in turn. My old method wouldn't change the background, and conditional formatting is not available with buttons. Even manually changing the background color in the button's property sheet didn't seem to do anything.
    PGT

  4. #4
    Join Date
    Jan 2005
    Posts
    146
    Instead create a text box control with the control source set to your button text (="ButtonAction"), set it to Locked to prevent editing and have it mimic a buttons action by placing the same code you have for the button in the on click event and also the KeyDown event to capture Enter key action.
    Code:
    Private Sub Text12_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
    MsgBox "test"
    End If
    End Sub
    It's not great, but will allow you to use conditional formatting.

  5. #5
    Join Date
    Aug 2006
    Posts
    126
    Thanks, for the additional idea. What I decided to do was to bump the FontSize from 6 to 7 and the FontWeight property from 400 (normal) to 700 (bold). This provided a visible change that worked nicely:
    Private Sub btnSameAsBotan_GotFocus()
    Me.ActiveControl.FontSize = 7
    Me.ActiveControl.FontWeight = 700
    End Sub
    Private Sub btnSameAsBotan_LostFocus()
    Me.ActiveControl.FontSize = 6
    Me.ActiveControl.FontWeight = 400
    End Sub
    PGT

  6. #6
    Join Date
    Jan 2005
    Posts
    146
    Glad you came up with a solution.

    Access is a great program, but Microsoft doesn't see it as a money winner and so never makes serious changes that so many people want to see. It would be great it MS sold it to someone who really cared and listened to the users and made changes that really matter like allowing controls to be changed as you are trying to do.

Tags for this Thread

Posting Permissions

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