Solved

On Focus Field Colour

Posted on 2011-02-18
6
267 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now