Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Problem with OptionButton click event

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Problem with OptionButton click event

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

"Patrick C. Simonds" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem with OptionButton click event

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 procedu

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.

"Patrick C. Simonds" wrote:

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


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Problem with OptionButton click event

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




"Dave Peterson" wrote in message
...
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 procedu

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.

"Patrick C. Simonds" wrote:

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


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem with OptionButton click event

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.



"Patrick C. Simonds" wrote:

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

"Dave Peterson" wrote in message
...
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 procedu

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.

"Patrick C. Simonds" wrote:

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


--

Dave Peterson


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Click event on menu item is lost after first time firing of the event [email protected] Excel Programming 1 April 2nd 07 01:25 PM
Click an Optionbutton jnf40 Excel Programming 5 August 29th 06 10:56 PM
userform label double-click goes to click event John Paul Fullerton Excel Programming 3 May 19th 06 05:54 PM
click event problem in excel 2003 only rferron Excel Programming 0 April 21st 05 05:43 PM
OptionButton problem Paul Excel Programming 1 June 14th 04 01:33 PM


All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"