tricky tabbing problem ???

G

Guest

I have a form with a number of combo boxes. one particular combo box has
'before update' and 'after update' procedures. the 'after update' procedure
changes the focus to another control so I set the focus back to the control
as the last statement in the 'after update' procedure.
Here is what is happening:
If I type the first letter of a valid choice and the auto-text fills in the
rest, then I press TAB, I go to the end of the text in the control and not to
the next control in the tab order. This only happens with this one combo box,
not the others.
My question. Why and how to fix it?
 
D

Dirk Goldgar

mscertified said:
I have a form with a number of combo boxes. one particular combo box
has 'before update' and 'after update' procedures. the 'after update'
procedure changes the focus to another control so I set the focus
back to the control as the last statement in the 'after update'
procedure.
Here is what is happening:
If I type the first letter of a valid choice and the auto-text fills
in the rest, then I press TAB, I go to the end of the text in the
control and not to the next control in the tab order. This only
happens with this one combo box, not the others.
My question. Why and how to fix it?

If you're setting the focus away from the comnbo box and then back to
it, in its AfterUpdate event, I expect that would do it. Why are you
doing that? I can't think of a good reason. Maybe you'd better post
your code.
 
K

Ken Snell [MVP]

Could also be code in the Exit event of the combo box that either cancels
the event or resets focus back to the combo box.
 
G

Guest

In the 'after update' event it does some complex logic that makes use of some
common routines. One of those common routines sets the focus to the first
control on the form. Basically, another control's (a listbox) contents
depends on the choice made in the combo box.
I'll see if I can avoid doing that but I was hoping there would be an easy
answer without going to all that trouble.
 
D

Dirk Goldgar

mscertified said:
In the 'after update' event it does some complex logic that makes use
of some common routines. One of those common routines sets the focus
to the first control on the form. Basically, another control's (a
listbox) contents depends on the choice made in the combo box.
I'll see if I can avoid doing that but I was hoping there would be an
easy answer without going to all that trouble.

Why should you need to set the focus to another control to determine or
set its value? Are you mistakenly using the control's Text property?
The Text property is only available when the control has the focus, but
the Value property (which is the default property of all the data
controls) is available at all times.
 
G

Guest

One of the tasks performed by the common routines is to enable/disable
various other controls based on the selection in the combo box. In order to
do this I must be sure that the focus is not on any control I am about to
disable, so I set the focus to the first control on the form (which is never
disabled). The common routines have no knowledge of where the focus currently
is. If there is a way to tell that I'd be home free.

Dorian
 
D

Dirk Goldgar

mscertified said:
One of the tasks performed by the common routines is to enable/disable
various other controls based on the selection in the combo box. In
order to do this I must be sure that the focus is not on any control
I am about to disable, so I set the focus to the first control on the
form (which is never disabled). The common routines have no knowledge
of where the focus currently is. If there is a way to tell that I'd
be home free.

Screen.ActiveControl.Name gives the name of the control that currently
has the application's focus. It raises an error if no control has the
focus. For any given form that is open, the form's own ActiveControl
property returns a reference to the control on *that* form that has the
focus, whether or not the form itself has the focus.
 

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