Solved

On Focus Field Colour

Posted on 2011-02-18
6
307 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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