Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

On Focus Field Colour

Posted on 2011-02-18
6
Medium Priority
?
341 Views
Last Modified: 2012-05-11
Hi all,

I have a form I am filling in with about 30 fields on.  I've seen in the conditional formatting menu that you can set a field to a different colour but from the looks of it I would have to set this for each individual field.  Is there any code I could use instead on the form to say whichever field the cursor is in to highlight it a different colour?

Thanks

Chris
0
Comment
Question by:smods
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 34924729
There is a sample here
http://msdn.microsoft.com/en-us/library/dd644812.aspx
The sample is for A2007 but the same code works in previous versions.
0
 

Author Comment

by:smods
ID: 34924772
Thank you! The sample DB file is not there! Grrr!
0
 
LVL 85
ID: 34924987
There was no sample database provided with the link Peter provided, but there was code that showed how to do this. It does require you to add event code to each control where you wish this to occur. The article did provide you with a method to add code to ALL those controls at once (i.e. highlight all the code and set the values of the GotFocus and LostFocus events, which will include that in ALL selected controls).

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:smods
ID: 34925147
Thanks LSM.  

There is a link as it states "Download the sample database" but when you click on it it says file not found.

I've also had a go with the code but some things I am not clear about:

2. Create two functions named SpecialEffectEnter and SpecialEffectExit that will toggle the values of the BackColor and SpecialEffect properties for the text boxes, and the common sub MakeActive, which does the work. Here are the code listings for the procedures.

Private Sub MakeActive(ctl As Control, active As Boolean)
    On Error GoTo HandleErr

    If active Then
        ' Set the current control to be indented
        ' Set the current control's background color to be white
        ctl.SpecialEffect = conIndent
        ctl.BackColor = conActiveColor
    Else
        ' Set the current control to be flat
        ' Set the current control's background color to be gray
        ctl.SpecialEffect = conFlat
        ctl.BackColor = conNonActiveColor
    End If
    
ExitHere:
    Exit Sub

HandleErr:
    ' Uncomment to debug:
    ' MsgBox Err & ": " & Err.Description
    Resume ExitHere
End Sub

Public Function SpecialEffectEnter()
    MakeActive Screen.ActiveControl, True
End Function

Public Function SpecialEffectExit()
    MakeActive Screen.ActiveControl, False
End Function

Open in new window


Does all above code go in both modules SpecialEffectEnter & SpecialEffectExit?  I'm just not clear about it.

On a side note can you help over here LSM?  http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_26828049.html
Thanks

Chris
0
 
LVL 85
ID: 34925509
The code listed in the example would go into ONE location - in a Standard Module, as directed by the example.  Once you insert that Function into the module, then would add the calls to the various functions, as described in section #4.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34927482
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question