If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
"Field has focus" condidional formatting - Not working
Hello, I have several sub forms with fields turning green when the field has
the focus (user click in it). However, I have a couple sub forms that refuse to cooperate, when I click in it nothing happens, the field remains white. The conditional formatting is enforced via the standard "Conditional Formatting" menu in MS Access 2003 with SP2. Does anyone know how to solve this mystery? Thanks, Silvio |
#2
|
|||
|
|||
"Field has focus" condidional formatting - Not working
"Silvio" wrote in message
... Hello, I have several sub forms with fields turning green when the field has the focus (user click in it). However, I have a couple sub forms that refuse to cooperate, when I click in it nothing happens, the field remains white. The conditional formatting is enforced via the standard "Conditional Formatting" menu in MS Access 2003 with SP2. Does anyone know how to solve this mystery? Silvio, this might be easier than setting up conditional formatting for all the controls. 1. Copy the code below into a standard module, and save with a name such as Module1. 2. For any form where you want to do this, set its OnLoad property to: =SetupHighlight([Form]) It programmatically sets up each control so it goes yellow when it gets focus, and goes back to white when it loses focus. It only works for text boxes and combos where the BackStyle is normal (not transparent), and GotFocus/LostFocus is not already in use. Public Function SetupHighlight(frm As Form) Dim ctl As Access.Control For Each ctl In frm.Controls Select Case ctl.ControlType Case acTextBox, acComboBox If ctl.BackStyle = 1 Then If (ctl.OnGotFocus = vbNullString) And _ (ctl.OnLostFocus = vbNullString) Then ctl.OnGotFocus = "=Hilight([" & ctl.Name & "], True)" ctl.OnLostFocus = "=Hilight([" & ctl.Name & "], False)" End If End If End Select Next End Function Public Function Hilight(ctl As Control, bOn As Boolean) Const lngcHilightOn = vbYellow Const lngcHilightOff = vbWhite If bOn Then ctl.BackColor = lngcHilightOn Else ctl.BackColor = lngcHilightOff End If End Function -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. |
#3
|
|||
|
|||
"Field has focus" condidional formatting - Not working
Thank you again Alllen, this works just fine!
"Allen Browne" wrote: "Silvio" wrote in message ... Hello, I have several sub forms with fields turning green when the field has the focus (user click in it). However, I have a couple sub forms that refuse to cooperate, when I click in it nothing happens, the field remains white. The conditional formatting is enforced via the standard "Conditional Formatting" menu in MS Access 2003 with SP2. Does anyone know how to solve this mystery? Silvio, this might be easier than setting up conditional formatting for all the controls. 1. Copy the code below into a standard module, and save with a name such as Module1. 2. For any form where you want to do this, set its OnLoad property to: =SetupHighlight([Form]) It programmatically sets up each control so it goes yellow when it gets focus, and goes back to white when it loses focus. It only works for text boxes and combos where the BackStyle is normal (not transparent), and GotFocus/LostFocus is not already in use. Public Function SetupHighlight(frm As Form) Dim ctl As Access.Control For Each ctl In frm.Controls Select Case ctl.ControlType Case acTextBox, acComboBox If ctl.BackStyle = 1 Then If (ctl.OnGotFocus = vbNullString) And _ (ctl.OnLostFocus = vbNullString) Then ctl.OnGotFocus = "=Hilight([" & ctl.Name & "], True)" ctl.OnLostFocus = "=Hilight([" & ctl.Name & "], False)" End If End If End Select Next End Function Public Function Hilight(ctl As Control, bOn As Boolean) Const lngcHilightOn = vbYellow Const lngcHilightOff = vbWhite If bOn Then ctl.BackColor = lngcHilightOn Else ctl.BackColor = lngcHilightOff End If End Function -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. |
Thread Tools | |
Display Modes | |
|
|