BACKGROUND:
I have a function taken from the O'Reilly Access Cookbook publication that causes an input control on a form to change background color.
It is placed in the OnGotFocus event of the control and a similar function is placed in the OnLostFocus event of the control.
Private Const conYellow = 7467773
Private Const conWhite = 16777215
Public Function SpecialEffectEnter()
On Error GoTo HandleErr
'Set the control's background color to yellow
Screen.ActiveControl.BackColor = conYellow
ExitHere:
Exit Function
HandleErr:
'MsgBox Err & ": " & Err.Description
Resume ExitHere
End Function
Public Function SpecialEffectExit()
On Error GoTo HandleErr
'Set the control's background color to white
Screen.ActiveControl.BackColor = conWhite
ExitHere:
Exit Function
HandleErr:
'MsgBox Err & ": " & Err.Description
Resume ExitHere
End Function
In addition in the OnOpen event of the form they say to place the following code:
me.setfocus
This prevents Access from using the Screen.ActiveControl before the form has fully loaded according to the CookBook.
This all works fine if it is a simple form ie. no page tabs etc.
[red]PROBLEM:[/red]
[highlight aqua]I have a form that has several tabbed pages, and each page has a subform. I cannot get this to work without an error message: "The expression you entered requires the control to be in the active window:
I have tried many configurations too numerous to mention but
I cannot figure out what I should be referencing for the me.setfocus part of this routine. I don't know if it's how I'm referencing them or if I'm referencing the wrong object.
Object names are as follows:
Form: "Main Form"
Page: "pgWellHeader"
Subform "Frm_WellHeader"[/highlight]
Any thoughts?
I have a function taken from the O'Reilly Access Cookbook publication that causes an input control on a form to change background color.
It is placed in the OnGotFocus event of the control and a similar function is placed in the OnLostFocus event of the control.
Private Const conYellow = 7467773
Private Const conWhite = 16777215
Public Function SpecialEffectEnter()
On Error GoTo HandleErr
'Set the control's background color to yellow
Screen.ActiveControl.BackColor = conYellow
ExitHere:
Exit Function
HandleErr:
'MsgBox Err & ": " & Err.Description
Resume ExitHere
End Function
Public Function SpecialEffectExit()
On Error GoTo HandleErr
'Set the control's background color to white
Screen.ActiveControl.BackColor = conWhite
ExitHere:
Exit Function
HandleErr:
'MsgBox Err & ": " & Err.Description
Resume ExitHere
End Function
In addition in the OnOpen event of the form they say to place the following code:
me.setfocus
This prevents Access from using the Screen.ActiveControl before the form has fully loaded according to the CookBook.
This all works fine if it is a simple form ie. no page tabs etc.
[red]PROBLEM:[/red]
[highlight aqua]I have a form that has several tabbed pages, and each page has a subform. I cannot get this to work without an error message: "The expression you entered requires the control to be in the active window:
I have tried many configurations too numerous to mention but
I cannot figure out what I should be referencing for the me.setfocus part of this routine. I don't know if it's how I'm referencing them or if I'm referencing the wrong object.
Object names are as follows:
Form: "Main Form"
Page: "pgWellHeader"
Subform "Frm_WellHeader"[/highlight]
Any thoughts?