|
-
Mar 6th, 2002, 11:28 PM
#1
Thread Starter
New Member
Newbie type option button question/problem.
I have a form with 3 option buttons on it, optYes, optNo and optMaybe. Selection of any option button pops up a corresponding message box. Now the problem is this. Whenever the form loads, the code for optYes fires. I have set the value of all three option buttons to False in the Form load, but still the same problem happens. I have even tried making and invisible option button, setting its value to True....same problem. Any ideas?
-
Mar 6th, 2002, 11:31 PM
#2
When you set the Value property of an option button, it fires the Click event. Try setting their values in the IDE.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 6th, 2002, 11:51 PM
#3
Thread Starter
New Member
Grrrrr, same problem. I've set the values for the 3 option boxes to false both in the IDE and when the form loads. For some reason, the Yes option box click event fires off as soon as the form loads.
-
Mar 7th, 2002, 12:27 AM
#4
Yeah, strange. The value of the first option button not set to False in the code is set to True when the form loads no matter what the value is set as in the IDE. If the code sets all opts to False it still fires a click event on the first opt (considering it being changed from True to False). I guess you would either need to put the buttons in a container (like a borderless frame) or set a flag when the form loads to skip the code in the opt click event. Seems like there is something we are missing...
-
Mar 7th, 2002, 12:46 AM
#5
Thread Starter
New Member
Ok, I tried the frame idea and got the same results :{ As for the other idea with the flag, I'm too much of a clueless n00b to know how to do it!
There has got to be some kind of easy answer to this one...it cant be this difficult!
-
Mar 7th, 2002, 12:58 AM
#6
I can't think. Anyway, here's the dirty flag method:
VB Code:
Dim flag As Boolean
Private Sub Form_Load()
flag = True
End Sub
Private Sub Option1_Click()
If flag = False Then
MsgBox Option1.Value
Else
Option1.Value = False
flag = False
End If
End Sub
-
Mar 7th, 2002, 03:00 AM
#7
PowerPoster
The value is only set 'automatically' if it is the first item in the form's taborder. Can u make another control be the first one? If not, use flags.
Regards
-
Mar 7th, 2002, 01:30 PM
#8
Thread Starter
New Member
I placed an invisible option button on the form, set its value to true (I tried false as well), set its taborder to 0.....same problem :{ Guess I'll have to go with the flag idea. Thanks for all the help guys.
-
Mar 7th, 2002, 01:36 PM
#9
What is the TabIndex of the option button that fires? If it is 0, then there is your problem.
-
Mar 7th, 2002, 06:56 PM
#10
Thread Starter
New Member
Originally posted by Hack
What is the TabIndex of the option button that fires? If it is 0, then there is your problem.
Originally it was set to 1. I added the invisible option button and set that item's tabindex to 0...same problem.
-
Mar 7th, 2002, 07:01 PM
#11
PowerPoster
If the new option button is invisible it defeats the purpose becos u cant set focus to an invisible control. If you have no other visible controls that you could make taborder = 0 then u will just have to use a flag method
-
Mar 7th, 2002, 07:06 PM
#12
Thread Starter
New Member
Originally posted by beachbum
If the new option button is invisible it defeats the purpose becos u cant set focus to an invisible control. If you have no other visible controls that you could make taborder = 0 then u will just have to use a flag method
Ah! I didnt know that you couldnt set focus to an invisible control. Now that you mention it though, it makes perfect sense. Looks like the flag method is it. Thanks again guys :}
-
Mar 8th, 2002, 07:18 AM
#13
Have you tried putting a break on the Form_Load and using F8 to walk through the code to see at what point the option button code is being fired?
-
Mar 8th, 2002, 07:37 AM
#14
Bouncy Member
what about if you set their Enabled property to False, then set the values, then set their Enabled propert to True afterwards?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|