Run a Procedure automatically

R

RICHARD BROMBERG

I have two combo boxes.



After the first one loses focus I manually click on the second and it runs
properly.







I want to change the operation so that when the first combo box loses focus
I want to automatically run a second procedure.



In effect I want to avoid having to manually click on the down arrow in the
Second combo box and then click on one of the items in the dropdown list.



Is there some way to do this?



I tried using DoCmd OpenQuery which kind of works but it actually opens
a new screen with the results of the Query displayed.

That's close but not exactly what I want.



Thanks
 
D

Douglas J. Steele

Call the second procedure in the LostFocus event of the first combo:

Private Sub Combo1_LostFocus()

Call MySub()

End Sub
 
M

Marshall Barton

RICHARD said:
I have two combo boxes.

After the first one loses focus I manually click on the second and it runs
properly.

I want to change the operation so that when the first combo box loses focus
I want to automatically run a second procedure.

In effect I want to avoid having to manually click on the down arrow in the
Second combo box and then click on one of the items in the dropdown list.


You can not use the lost focus event to change the focus to
a different control, because the focus is already in the
process of moving.

If you wait until the LoastFocus or Exit event, then the
user has already clicked somewhere outside the firs combo
box. and it will still require them to click the arrow to
drop the list.

To avoid clicking the second combo box's arrow, you need to
set the focus to the second combo box first.

Combining all that, I think you want to use the first combo
box's AfterUpdate event to move to the second combo box and
drop its list:

Me.combo2.SetFocus
Me.combo2.DropDown
 
R

RICHARD BROMBERG

many thanks
Dick B
Marshall Barton said:
You can not use the lost focus event to change the focus to
a different control, because the focus is already in the
process of moving.

If you wait until the LoastFocus or Exit event, then the
user has already clicked somewhere outside the firs combo
box. and it will still require them to click the arrow to
drop the list.

To avoid clicking the second combo box's arrow, you need to
set the focus to the second combo box first.

Combining all that, I think you want to use the first combo
box's AfterUpdate event to move to the second combo box and
drop its list:

Me.combo2.SetFocus
Me.combo2.DropDown
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top