Results 1 to 6 of 6
  1. #1
    Join Date
    May 2014
    Posts
    14

    Unanswered: How to Highlight A Field Access 2013

    Can anyone explain to me or can refer me to a YouTube link which shows. What properties to set on a form which will allow selected fields on the form to highlight when there selected and return to default color when they are no longer selected. So as you tab thru form the field you are on is highlighted. I hope that makes sense  Thanks Everyone for all your help. I am using Access 2013

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    As answered elsewhere, you can use Conditional Formatting to do this.
    Paul

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Assuming you are NOT using continuous forms OR datasheet view then you can do what you want by placing code behind event hooks for each control
    each control has a GOTFOCUS and LOSTFOCUS event which triggers when the control gets the focus (selected) or looses it.
    say you want to set the background colocolour for the selected code to red (im going to use the inbuilt vba costant vbRed, but yoy can set a colour using a long that specifies the mix of colours.

    say the fiest control is called mycontrol, then in the mycontrol.gotfocus event...
    mycontrol.backcolor = vbRed

    In the mycontrol.lostfocus event..
    mycontrol.backcolor = vbWhite
    'OR perhaps safer mycontrol.backcolor = me.backcolor

    either open a code window or rightclick on the relevant controls, select the relevant rab and then build the event.

    Personally i wouldn't do thus as I feel it makes the form garish, but each to their own I have used this sort of technique to highlight required or cobtrols with invalid data
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    As Paul said, a simple step-by-step (only 5 steps) for this is given here

    http://www.accessforums.net/forms/hi...use-49984.html

    where the question was double-posted.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    My reading of the question is that a try to G email requirement is to highlight selected 'fields' so as you tab on the 'field' it highlights.
    So unless conditional formatting has changed recently it will not meet that requirement. CF is perfect for identifying trends in data, or giving visual clues for say errors. But it won't alter when you tab onto or off the 'field', control in Access speak. The only way I know of doing that is as suggested above use the got focus and lost focus events.

    It may well be that CF can do this, but as I dislike it's inflexibility and primarily prefer writing code to do the job myself I nearly always use code. One of my main gripes with cf is that unless you comment the code that you are using CF it can cause maintenance issues with legacy code. It also only allows is it 3 or 4 states. On top of which it requires developer intervention to change colours or trigger points.

    So for me put code in the gotfocus and lostfocus events if you want to change something as the control is selected.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Nov 2008
    Posts
    24

    Highlight a field

    to highlight a field on a form there are a number options available. The one I will discuss here is to highlight one field at a time using the on mouse move event (this can be used for onfocus etc)
    In form design I set the On mouse enter event to "=fSetHighlight([the controls name])"
    in the VBA portion
    In the global section
    Dim mstPrevControl As String
    Function fRemoveBold()
    If bold_on = False Then Exit Function
    Call fRemoveFontBold
    End Function

    Function fSetFontBold(stControlName As String)
    On Error Resume Next
    If bold_on = True Then Exit Function

    With Me(mstPrevControl)
    .FontWeight = cNormal
    .BorderStyle = 0
    ' .SpecialEffect = 0
    'If Me(mstPrevControl).ControlType = acLabel Then
    ' .BorderStyle = 0
    'Else
    ' .BorderStyle = 8
    'End If
    '.ForeColor = 0
    .BackColor = WHITE
    .FontUnderline = False
    End With
    mstPrevControl = stControlName

    With Me(stControlName)
    .FontWeight = cBold
    .FontUnderline = True
    If Me(stControlName).controltype = acLabel Then
    .BorderStyle = 8
    ' .SpecialEffect = 2
    Else
    .BorderStyle = 0
    ' .SpecialEffect = 0
    End If
    '.BorderStyle = 1
    '.ForeColor = 255
    .BackColor = Light_yellow
    End With
    bold_on = True
    Hover_over = True
    End Function

    Function fRemoveFontBold()
    On Error Resume Next
    If bold_on = False Then Exit Function
    With Me(mstPrevControl)
    Me.Caption = "Main Menu"
    Me!LblMessage.Caption = "Messages"
    StatusBarMsg ("")
    .FontWeight = cNormal
    .FontUnderline = False
    .BorderStyle = 0
    .BackColor = WHITE
    End With
    bold_on = False
    Hover_over = False
    End Function
    Function fSetControlOption(Ctl As Access.Control)
    Dim strControlTag As String
    Dim strControlName As String
    strControlTag = Ctl.tag
    strControlName = Ctl.Name
    Me.Caption = "Select the " & Ctl.ControlTipText
    Me!LblMessage.Caption = Me.Caption
    StatusBarMsg (Me.Caption)
    Call fSetFontBold(strControlName)
    End Function

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
  •