Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

On Focus Field Colour

Posted on 2011-02-18
6
Medium Priority
?
352 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 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

876 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