Re: Is this a bug in VB?



Gord wrote:

I am writing some VB code in a combo box's 'On Click' event on a form. It would appear the event fires when a selection is clicked on from the available drop down list. This is about what I would expect to happen and so my code runs just fine.

However, if any editing is done in the box (i.e. don't select from the list and just type my own entry, or perhaps make changes to what was selected from the drop down list) and then I click on some other control on the form, then the 'On Click' event fires for the combo box? (It looks more like a 'Lost Focus' event to me!).

Is this some bug in VB or am I misunderstanding the event? I've gone to Microsoft's web for Office updates and it says everything's up to date.

Thanks,

Gord


I created a new form; A97. 2 Controls; Combo with with values; 1,2,3,4 and a command button to close the form.

If I tab between the two controls and change the value by entering 1,2,3,4 it executes the click or after update event depending on the value entered. Same with clicking on the dropdown values and selecting.
Private Sub Combo0_AfterUpdate()
If Me.Combo0 < 3 Then MsgBox "After Less than 3"
End Sub
Private Sub Combo0_Click()
If Me.Combo0 > 2 Then MsgBox "Click Greater than 2"
End Sub

I changed the code to
Private Sub Combo0_AfterUpdate()
If Me.Combo0 < 3 Then
MsgBox "After Less than 3"
Else
MsgBox "After Greater than 2"
End If
End Sub
Private Sub Combo0_Click()
If Me.Combo0 > 2 Then
MsgBox "Click Greater than 2"
Else
MsgBox "Click Less than 3"
End If
End Sub

It always executed the AfterUpdate then the Click event; by entering the values and tabbing or selecting the values from the dropdown via the mouse.

Here's what A97 help says
For a control, this event occurs when the user:

· Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.
· Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

· Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.
· Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.
· Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

· Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.
· Presses a control's access key. For example, if a command button's Caption property is set to &Go, pressing ALT+G triggers the event.

When I change the value and tab...I don't see that listed as an action that would activate the OnClick event.

Is it a bug? I'll let the experts decide.
.