Gennie,
I think you may need to give more details. For me, using a form with one
text box and one command button (VB5) it works as expected - the lost focus
event firing and then the click event.
With a combo box it also appears to work, although the click event on a
combo box is fired when an item is selected in the list, not when it gets
the focus via a mouse click. To trap on that event you need to trap on the
GotFocus event.
Regarding the toolbar, I think you will find that the toolbar cannot take
the focus, and thus the focus is left on the text box and the LostFocus
event is not triggered. This can easily be gotten around by having the
toolbar explicitly call the LostFocus event as in Text1_LostFocus.
If you don't know what text box has the focus, there are several strategies
you could consider. Probably the easiest one arises if there is a text box
that you can safely switch focus to (i.e. one that doesn't have any
validation). Assume it is called Text2. You can then proceed as follows:
Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)
Dim c As Control
Set c = Me.ActiveControl
Text2.SetFocus ' Triggers the lost focus event of active control
c.SetFocus
Set c = Nothing
' Your code
End Sub
HTH
Peter
Quote:
>Hello. I am using the lostfocus events of the text boxes on my form for
>validation purposes. It turns out that if you click on another control
like
>a command button or a combo box, thereby losing focus on the text box, the
>click event of that other control is not triggered and it only goes through
>the lostfocus event of the textbox. I've also found that if I click on the
>toolbar of the same form, it does go through the buttonclick event of my
>toolbar but does not go through the lostfocus event of the textbox.
>I need both event to be performed. Help!!!
>Gennie Marasigan