Setting tab page to zero when it gets the focus

G

Guest

Access 2003

When I tab out of the previous control on the form (combo box), and land on
the tab control, I want to automatically go to the first tab. However, I
cannot find an event associated with the tab control getting the focus.

I also have some code associated with the Change event of the tab, so that
when I click on a tab, the focus automatically moves to the first control on
that tab. This work if I am actually changing the tab that is selected, but
if I click on a tab that already has the focus, the Change event of the tab
doesn't fire.

Any recommendations?
 
J

John Nurick

To me the logical thing would be to put code in the combo box's Exit
event to set the Page property of the tab control and then if necessary
focus on the first control on that page. Otherwise, every time the user
clicked somewhere else and then back on the tab control it would switch
back to the first page, which sounds undesireable.

But I haven't tried it and there could be complications...
 
D

Dale Fye

John,

Don't think the OnExit event will do what I want, because it will fire every
time I exit that control, whether I tab out of it, hit enter, or click on
another control. I thought maybe I could use the KeyPress event and test
for the Tab or Enter key, and if either of those keys was pressed, jump to
the first page of the tab control, but I cannot seem to get that to work
either.

I guess I could use the Exit event and test to see whether it is a new
record, then move to the first page of the tab. I'll give that a try and if
it does not work, I'll keep looking for other alternatives.

Dale
 
J

John Nurick

From memory, jumping to the first page needs something like this:

With Me.TabControl
.Value = 0
.Pages(0).Controls("FirstControl").SetFocus
End With
 

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