Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option1_click() Fired at Load Time 3

Status
Not open for further replies.

chequi

IS-IT--Management
Apr 24, 2000
24
PR
In VB6 - I am having the following problems:
(1) A form with an option object at load time makes the option1_Click fired automatically (without any click).
(2) when option1(0) or option1(1) is selected it does not fire option1_click when clicked ; this is, I can not activate option1_click twice in a row.

Above situation also hapens with the SSTAB object.

Any suggestion to solve this problem?. Thanks in advance.

Chequi.
 
Hi,

When the form loads set the option buttons value to false. The focus is then set to the next object on the form. However if no other objects are on the form the focus then goes back to the first option button because option1 has the lowest tab index. Instead of using the event onclick you can use the mouseup event procedure instead. Below is the code I used to test this. The form had 2 option buttons and one command button to get the focus.


Option Explicit

Private Sub Form_Load()
Me.Option1.Value = False
Me.Option2.Value = False
End Sub

Private Sub Option1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox "Option1 Clicked !”
End Sub


Hope this helps you !
 
Its annoying, but the way I overcame it was to put a variable in front of my onclick code. If the variable = 0 then exit sub. After the programme loaded, I reset the variable. Bit of a bodge, but it got me out of my problem. I think from memory, I had to put in a value of 1 prior to checking which open was ticked as well, and then reset it back to zero after it had finished. Maybe someone else has a real solution. Be good to hear one. Regards
 

Do you have any other controls on the form that can recieve the focus??? If so change your tab order around if it is feasible. If Not, set the tabstop to false (in properties or see below) thus making the user have to use the mouse or something like
[tt]
Private Sub Form_Load()
Option1(0).TabStop = False
Option1(1).TabStop = False
'do other initialization here
Me.Show'you can't do this if this form is being shown modally
Option1(0).TabStop = True
Option1(1).TabStop = True
End Sub
[/tt]

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top