optionbuttons - strange behavior with controlcource

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,341
I have a userform with 2 optionbutton (only 2).
If one button is clicked it becomes 'true' and the other becomes 'false', and vice versa. This is exaclty what should happen, so that's fine.

If I attach a control source to each button (so that the selected option is remembered when the form loads), then , on clicking the one that id false, the other one becomes false, but the one clicked remains false also. I have to click it again to get it to be true. Inspection of the cells that are the controlsources shows that when this happens, both cells accurately treflect the optionbuttons' status ie they go from
True+False (Initial state)
False+False (afetr first click)
False+True (afetr second click)
anyone know what causes this effect. It's very annoying,
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I can't reproduce that behaviour in Excel 2000. For the ControlSource I had Sheet1!A1 and Sheet1!A2. What have you got?
 

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,341
I have exactly the same. The sheet is not protected or hidden, and the form that is loaded is loaded from sheet1 (ie it is the activesheet) But I still get this annoying behaviour.
 

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,341

ADVERTISEMENT

To demo the problem I created a new workbook. There is a single userform with just 2 optionbuttons. There is a command button on sheet1 whose code is 'Userform1.show'. That's the lot! No other code, forms or anything else. The behaviour is causing problems in a 'real' application,. but before posting the query I just wantedto make sure that nothing else could be interfering, hence the new workbook......This happens when it's the only open workbook (even personal.xls is closed). There are some addiins, but I have always had these as far as I know. Interestingly, once I ghave been throught the first cycle (ie have clicked the 'false' button twice to set it to true) they then subsequently behave correctly (ie only one click is need to change them)
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
With your setup, both Options buttons are checked (but in an indeterminate state) when I first show the form, because A1 and A2 are blank. Clicking either one immediately sets it to True and the other to False.

That's with Excel 2000 SR-1 9.0.3821.
 

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,341
Mine's 9.0.8948 SP-3
I get the same as you if the cells are blank, What I am talking about is the 'normal' situation where one cell is false and the other is true.
Just to be clear.
1. Load form.
Button1 is checked. Its CS is 'TRUE'
Button2 is not checked. Its CS is 'FALSE'
2. Click button2
Button1 is not checked. Its CS is 'FALSE'
Button2 is not checked. Its CS is 'FALSE'
3. click button2 again
Button1 is not checked. Its CS is 'FALSE'
Button2 is checked. Its CS is 'TRUE'

If you can't reporduce it then maybe Ijust have to live with it. Maybe there's something wrong with Excel - I'll try a detect and repair when I get time. ANy other ideas welcomed, thanks for your time so far.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,041
Messages
5,545,685
Members
410,697
Latest member
srishtijain0708
Top