Message 1 of 5
Click event runs when initializing a check box?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an event procedure for my check box intended to be ran if the user clicks the control… but for some reason the event procedure is running when I put a check mark in the control … even before the form gets to the screen. Below are the three procedures.
Public Sub Main()
‘ this code runs first…
‘ do some stuff
UserForm1.Show ‘ fires UserForm_Initialize event
End Sub
‘*************************************
Private Sub UserForm_Initialize()
‘ do some stuff here
‘ then initialize my check box…
initMyCheckBox ‘ run sub procedure to initialize check box
End Sub
‘*************************************
Private Sub initMyCheckBox ()
' check & set status
‘ if condition is true then set the value of the check box to True
If condition Then
MyCheckBox.Value = True ‘ << runs MyCheckBox _Click event… WHY???
MyCheckBox.Enabled = False
End If
End Sub
‘*************************************
Private Sub MyCheckBox _Click()
‘ If user clicks to place a check in the check box then…
‘ ….. do some stuff
‘ else
‘ ….. do some other stuff.
If MyCheckBox.Value = True Then
‘do some stuff
Else
‘do some other stuff
End If
End Sub
Public Sub Main()
‘ this code runs first…
‘ do some stuff
UserForm1.Show ‘ fires UserForm_Initialize event
End Sub
‘*************************************
Private Sub UserForm_Initialize()
‘ do some stuff here
‘ then initialize my check box…
initMyCheckBox ‘ run sub procedure to initialize check box
End Sub
‘*************************************
Private Sub initMyCheckBox ()
' check & set status
‘ if condition is true then set the value of the check box to True
If condition Then
MyCheckBox.Value = True ‘ << runs MyCheckBox _Click event… WHY???
MyCheckBox.Enabled = False
End If
End Sub
‘*************************************
Private Sub MyCheckBox _Click()
‘ If user clicks to place a check in the check box then…
‘ ….. do some stuff
‘ else
‘ ….. do some other stuff.
If MyCheckBox.Value = True Then
‘do some stuff
Else
‘do some other stuff
End If
End Sub