Set Focus on tabs

A

akoganslm

i have a tab control w/ a bunch of tabs. most of these tabs have
subform (or 2). to increase performance, the subforms are unbound
until the tab is clicked (i do this w/ code). this works well.

the issue is when i click on one of the tabs w/ a subform, i can NOT
use the Tab key; i get a Windows 'beep' (no error message). it is as
if there is NO focus on any control. if i click in a subform/control
on that tab, i can then use the Tab key to navigate. this is annoying
as it slows down data entry because i then have to use the mouse.

this does NOT happen if: i remove the code that sets the subforms OR i
click on a tab without any subforms.

i have used the .SetFocus in every way i can think of to make this
work but no luck.

please help!
 
S

Steve

Open your form in design view. Select a subform control and check ita
properties;
Lock = No
Tab Stop Yes

Also check the tab order of the form to see if all controls are in the right
tab order.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
A

akoganslm

Open your form in design view. Select a subform control and check ita
properties;
Lock = No
Tab Stop Yes

Also check the tab order of the form to see if all controls are in the right
tab order.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)

thanks for the reply.
yes, that is how it is set.
 
A

akoganslm

thanks for the reply.
yes, that is how it is set.

once i click on the tab or a control on the tab, i can then use the
Tab key just fine. it is as if the Focus is temporarily gone.
 
S

Steve

Post the code that binds your subform.

What is the name of the subform control? Not the subform!

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
A

akoganslm

Post the code that binds your subform.

What is the name of the subform control? Not the subform!

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)

the subform control name is diffferent for each subform. furthermore,
if you look at the code listed below, the name does not matter as it
loops thru all the controls on a page and if it finds a subform it
sets it's SourceObject to the Tag property (where i store the actual
form object).

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Start Code

Dim frm As Form
Dim ctl As Control
Dim tbc As Control
Dim pge As Page
Dim strPage As String

Set frm = Forms(strForm)

Set tbc = frm.Controls(strTbc) ' Return reference to tab control.
Set pge = tbc.Pages(tbc.Value) ' Return reference to currently
selected page.

' for each control on form, if it is a subform, set it to
its .SourceObject to nothing
For Each ctl In tbc.Controls
If ctl.ControlType = acSubform Then
If ctl.SourceObject <> "" Then
ctl.SourceObject = ""
End If
End If
Next

For Each ctl In pge.Controls ' for each control on current page,
if it is a subform, set it to its .SourceObject to its .Tag property
If ctl.ControlType = acSubform Then
If ctl.SourceObject = "" Then
ctl.SourceObject = ctl.Tag
End If
End If
Next

Set frm = Nothing
Set tbc = Nothing
Set pge = Nothing
Set ctl = Nothing

'End Code
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

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