Hi All,
Attempting to change a control's backcolor via a variable. Calling sub changeBackColors and setting strControlName to current control. Problem is when I attempt to execute Me!strControlName.BackColor = vbYellow, I get a syntax error. I know my syntax at Me!strControlName is wrong, but can't remember how to set this up.
Public Sub changeBackColors(strAction As String)
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
MsgBox "strControlName is ... " & strControlName
If strAction = "OnClick" Then
Me!strControlName.BackColor = vbYellow
Else
'Me!strControlName.BackColor = vbWhite
End If
End Sub
Any help would be appreciated.
Thanks,
Tim
Attempting to change a control's backcolor via a variable. Calling sub changeBackColors and setting strControlName to current control. Problem is when I attempt to execute Me!strControlName.BackColor = vbYellow, I get a syntax error. I know my syntax at Me!strControlName is wrong, but can't remember how to set this up.
Public Sub changeBackColors(strAction As String)
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
MsgBox "strControlName is ... " & strControlName
If strAction = "OnClick" Then
Me!strControlName.BackColor = vbYellow
Else
'Me!strControlName.BackColor = vbWhite
End If
End Sub
Any help would be appreciated.
Thanks,
Tim