Problem with OptionButton click event

P

Patrick C. Simonds

Is there any way to run the code below without triggering the Click Event
associated with the OptionButton?

If rng1(1, 8) = "YES" Then
OptionButton2202.Value = True
End If
If rng1(1, 8) = "NO PHONE" Then
OptionButton2203.Value = True
End If
If rng1(1, 8) = "LEFT MESSAGE" Then
OptionButton2205.Value = True
End If
If rng1(1, 8) = "NOT CALLED" Then
OptionButton2206.Value = True
End If
 
F

FSt1

hi
since you didn't post all of your code, i am guessing.
if your sub start with....
Private Sub OptionButton1_Click()
then you need to change this to another event.
what event? you have to have some event to trigger code to run.
you could put the code into a standard module, attach the code to a button
then use it's click event to run the code.

what's wrong with the click event?

regards
FSt1
 
D

Dave Peterson

Set up a module level boolean variable:

At the top of your code:

Option Explicit
Dim BlkProc as boolean

....

Then in your procedure that changes these values:
If rng1(1, 8) = "YES" Then blkproc = true
OptionButton2202.Value = True blkproc = false
End If


Then in the optionbutton2202_click procedure:

Sub Optionbutton2202_click()
if blkproc = false then exit sub
...
rest of your code here
end if

This doesn't actually stop the triggering of the events--it just stops them from
doing anything meaningful.
 
P

Patrick C. Simonds

Not sure I gave enough code to explain what my problem is, so I have
included the code from the click event:

Normally when I click on OptionButton2201 I want the click event to run, but
when I edit TextBox2203 and the code under Else runs (setting the
OptionButtons) I do not want tit to trigger the OptionButton click event.
The reason I do not want it to run is because then the OptionButton click
events clears TextBox2203.

I know this is not the most efficient coding but it is what I am capable of
at this time.



Private Sub TextBox2203_Change()

If Me.Visible = False Then Exit Sub

Me.TextBox2203 = UCase(Me.TextBox2203.Text)

If TextBox2203.Value <> rng1(1, 7) Then

If OptionButton5001.Value = True Then

GoTo Skip
End If

OptionButton2201.Value = False
OptionButton2202.Value = False
OptionButton2203.Value = False
OptionButton2204.Value = False
OptionButton2205.Value = False
OptionButton2206.Value = False

Frame11.BackColor = &H80FFFF
Frame11.BorderColor = &HFF&

ComboBox2201.Value = ""
ComboBox2202.Value = ""

ComboBox2201.BackColor = &H80FFFF
ComboBox2202.BackColor = &H80FFFF

Else

Frame11.BackColor = &H8000000F
Frame11.BorderColor = &H80000012

If rng1(1, 8) = "NO" Then
OptionButton2201.Value = True
If rng1(1, 8) = "YES" Then
OptionButton2202.Value = True
End If
If rng1(1, 8) = "NO PHONE" Then
OptionButton2203.Value = True
End If
If rng1(1, 8) = "LEFT MESSAGE" Then
OptionButton2205.Value = True
End If
If rng1(1, 8) = "NOT CALLED" Then
OptionButton2206.Value = True
End If

ComboBox2201.BackColor = &H80000005
ComboBox2202.BackColor = &H80000005

ComboBox2201.Value = rng1(1, 16).Text
ComboBox2202.Value = rng1(1, 15).Text

End If

TextBox2203.BackColor = &H80000005
TextBox2203.SetFocus
GoTo Done
Skip:
TextBox2203.BackColor = &H80000005

Done:

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub OptionButton2201_Click()
'No

If Me.Visible = False Then Exit Sub

TextBox2203.Value = ""
TextBox2203.BackColor = &H80FFFF
OptionButton2201.Value = True

TextBox2205.Value = Now()
Me.TextBox2205.Value = Format$(Now(), "ddd dd mmm yy")

TextBox2212.Value = Now()
Me.TextBox2212.Value = Format$(Now(), "HH:MM")

Frame11.BackColor = &H8000000F
Frame11.BorderColor = &H80000012

End Sub
 
D

Dave Peterson

Nope. You shared enough code.

Your challenge will be to put in that variable and add the lines before and
after each line that causes the event to fire.

And to add that line to the top of the procedure you want to stop.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top