I'm getting stuck here. I made a simple form (called Test) with an option group with 2 option buttons (optBlue and optRed). I have a label called lblTest and a command button called cmdGo. The cmdGo has an On_Click() property set to event procedure. The code for the cmdGo calls function ChangeColor that exists in a regular module. When thr form is run pushing the cmdGo button should change the backcolor of the label based on what option button is selected. This is the code that I have written:
Form Module:
Option Compare Database
Option Explicit
Private Sub cmdGo_Click()
Call ChangeColor
End Sub
Regular Module:
Option Compare Database
Public Blue As String
Public Red As String
Public optgrpColor As OptionGroup
Public lblTest As Label
Public Test As Form_Test
Option Explicit
Function ChangeColor()
Set optgrpColor = Test
Select Case optgrpColor
Case 1
lblTest.BackColor = vbBlue
Case 2
lblTest.BackColor = vbRed
End Select
End Function
I'm getting an error when trying to set optgrpChangeColor
I get run-time error 91. Object variable or With block variable not set.
I'm not familiar enough with VBA to figure out how to fix this. If anyone could look at my code and see what it is that I'm doing wrong I sure would appreciate it.
Thanks.
[This message has been edited by Mendel (edited 03-13-2001).]
Form Module:
Option Compare Database
Option Explicit
Private Sub cmdGo_Click()
Call ChangeColor
End Sub
Regular Module:
Option Compare Database
Public Blue As String
Public Red As String
Public optgrpColor As OptionGroup
Public lblTest As Label
Public Test As Form_Test
Option Explicit
Function ChangeColor()
Set optgrpColor = Test
Select Case optgrpColor
Case 1
lblTest.BackColor = vbBlue
Case 2
lblTest.BackColor = vbRed
End Select
End Function
I'm getting an error when trying to set optgrpChangeColor
I get run-time error 91. Object variable or With block variable not set.
I'm not familiar enough with VBA to figure out how to fix this. If anyone could look at my code and see what it is that I'm doing wrong I sure would appreciate it.
Thanks.
[This message has been edited by Mendel (edited 03-13-2001).]