Hi,
I'm trying to add some bells an whistles to an app and allow users to choose their own colour scheme.
The user gets to choose 3 colours which are stored in a table and are loaded up into global variables during FrmSplash. This works great and I'm able to change my other forms to the users colour scheme as each form is loaded by listing each element separately.
I then came across some code in these forums that I adapted to try and loop through each element without having to list each one.
My code is:
This should go through each control and if the first three letters on the controls name is either lbl or box it will change the Fore or Back colour appropriately.
Unfortunately I get the following error....
Run-time error '2475'
You entered an expression that requires the form to be the active window.
I have tried the code in the forms;
On Open
On Load
On Active
On Current Events with the same error.
Any help would be appreciated.
I'm trying to add some bells an whistles to an app and allow users to choose their own colour scheme.
The user gets to choose 3 colours which are stored in a table and are loaded up into global variables during FrmSplash. This works great and I'm able to change my other forms to the users colour scheme as each form is loaded by listing each element separately.
I then came across some code in these forums that I adapted to try and loop through each element without having to list each one.
My code is:
Code:
Dim ctlX As Control
Dim frm As Form
Set frm = Screen.ActiveForm
FormHeader.BackColor = GlbHeaderBackColour
FormFooter.BackColor = GlbHeaderBackColour
Section(acDetail).BackColor = GlbDetailBackColour
For Each ctlX In frm.Controls
If Left$(ctlX.Name, 3) = "lbl" Then
ctlX.ForeColor = GlbHeaderForeColour
Else
If Left$(ctlX.Name, 3) = "box" Then
ctlX.BackColor = GlbHeaderBackColour
End If
End If
Next
Set ctlX = Nothing
This should go through each control and if the first three letters on the controls name is either lbl or box it will change the Fore or Back colour appropriately.
Unfortunately I get the following error....
Run-time error '2475'
You entered an expression that requires the form to be the active window.
I have tried the code in the forms;
On Open
On Load
On Active
On Current Events with the same error.
Any help would be appreciated.