Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Anyone know why this doesn't work ?


There's a Form with 2 checkboxes and these Click events

Private Sub chkK1_Click()
chkK1 = True
chkA1 = False
Application.StatusBar = "chkK1"
End Sub

Private Sub chkA1_Click()
chkA1 = True
chkK1 = False
Application.StatusBar = "chkA1"
End Sub


The intent is, as chkK1 is ticked, chkA1 will bceome unticked and Vice
versa.

But it doesn't work! How can it NOT work ???

I've also tried .Value = and .Caption = and removed' = True'
(in case that was automatic), but still no go.

What am I doing wrong? At least the Application.StatusBar message
works !

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default Anyone know why this doesn't work ?

kirkm wrote:
There's a Form with 2 checkboxes and these Click events

Private Sub chkK1_Click()
chkK1 = True
chkA1 = False
Application.StatusBar = "chkK1"
End Sub

Private Sub chkA1_Click()
chkA1 = True
chkK1 = False
Application.StatusBar = "chkA1"
End Sub


The intent is, as chkK1 is ticked, chkA1 will bceome unticked and Vice
versa.

But it doesn't work! How can it NOT work ???

I've also tried .Value = and .Caption = and removed' = True'
(in case that was automatic), but still no go.

What am I doing wrong? At least the Application.StatusBar message
works !

Thanks - Kirk


So what happens? I would expect, by reading this code, that you could
only untick a box by ticking the other one.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Anyone know why this doesn't work ?

On Wed, 29 Jul 2009 18:24:22 -0400, smartin
wrote:


So what happens? I would expect, by reading this code, that you could
only untick a box by ticking the other one.


That's exactly what I want, i.e you can only choose one of them.
But what does happen is odd. Try it out. I think Excels applying a
built in toggle which won't disable.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default Anyone know why this doesn't work ?

kirkm wrote:
On Wed, 29 Jul 2009 18:24:22 -0400, smartin
wrote:


So what happens? I would expect, by reading this code, that you could
only untick a box by ticking the other one.


That's exactly what I want, i.e you can only choose one of them.
But what does happen is odd. Try it out. I think Excels applying a
built in toggle which won't disable.


Works as expected. I click on box 1 and, regardless of its previous
state, it becomes or remains selected, box 2 becomes or remains
unselected, and status bar reads box 1. Similar for box 2. And, box 1
and box 2 always have opposite state.

What are you trying to do? If you want mutually exclusive selections,
options buttons are the control of choice.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Anyone know why this doesn't work ?

On Wed, 29 Jul 2009 22:40:21 -0400, smartin
wrote:



Works as expected. I click on box 1 and, regardless of its previous
state, it becomes or remains selected, box 2 becomes or remains
unselected, and status bar reads box 1. Similar for box 2. And, box 1
and box 2 always have opposite state.


Weird. That sounds like what I wanted it to do.... but doesn't.
The first click on Box1 select 1 with Box2 is unselected. Then click
Box2 and nothing happens. (Except the status bar message)

What are you trying to do? If you want mutually exclusive selections,
options buttons are the control of choice.


Yes, that works. But check boxes were preferred.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Anyone know why this doesn't work ?

On Wed, 29 Jul 2009 21:26:43 +1200, kirkm wrote:


There's a Form with 2 checkboxes and these Click events

Private Sub chkK1_Click()
chkK1 = True
chkA1 = False
Application.StatusBar = "chkK1"
End Sub

Private Sub chkA1_Click()
chkA1 = True
chkK1 = False
Application.StatusBar = "chkA1"
End Sub


The intent is, as chkK1 is ticked, chkA1 will bceome unticked and Vice
versa.

But it doesn't work! How can it NOT work ???

I've also tried .Value = and .Caption = and removed' = True'
(in case that was automatic), but still no go.

What am I doing wrong? At least the Application.StatusBar message
works !

Thanks - Kirk


A problem with your code seems to be that the manipulation of the
checkbox value from inside the code also fires the click event.
You thereby get into an "infinite loop" that is only interrupted
because some internal event buffer (or what it might be called) gets
overloaded.
Put this statement as the first statement of any of you click
procedures and you will see from the behaviour of cell A1 what I mean

Worksheets("Sheet1").Cells(1, 1) = Worksheets("Sheet1").Cells(1, 1)
+ 1

In my case, Excel 2007, cell A1 is increased to 284 before Excel
"gives up".

I suggest you use radiobuttons instead of checkboxes is you want the
mutual exlusive property. If you insist on using checkboxes, you will
have to try to find the "source" of the click event to see if it is a
mouse click or from user code. I don't know if that is possible in
VBA.

Hope this helps / Lars-Åke


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
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
HOW TO MAKE A LIST OF WORK SHEET IN WORK BOOK IN EXCEL 2007 goutam Excel Programming 1 February 1st 08 07:40 AM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


All times are GMT +1. The time now is 03:52 PM.

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

About Us

"It's about Microsoft Excel"