Solved

On Focus Field Colour

Posted on 2011-02-18
6
298 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
6 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 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 84
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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 84
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

766 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