TabIndex and TabControl

R

raymondskelton

How do I tab from a control on page 1 to a control on page 2 on a
TabControl? I have tried to set the TabIndexes manually on form load
but I get an error. See the following

Code:

Private Sub Form_Load()
Me!txtMake.TabIndex = 0
Me!txtModel.TabIndex = 1
Me!txtSerialNumber.TabIndex = 2
Me!txtExpressServiceCode.TabIndex = 3
Me!txtPurchaseDate.TabIndex = 4
Me!chkProduction.TabIndex = 5
Me!cmbPDLocationID.TabIndex = 6
Me!txtFunction.TabIndex = 7
Me!cmbCPUCount.TabIndex = 8 'Page one
Me!txtCPUSpeed.TabIndex = 9
Me!txtCPUType.TabIndex = 10
Me!txtRAMAmount.TabIndex = 11
Me!subArrays.TabIndex = 12
Me!txtOSInstalled.TabIndex = 13 'Page Two
Me!subInstalledSoftware.TabIndex = 14
Me!txtDNSName2.TabIndex = 15 'Page Three
Me!txtPrimaryIP.TabIndex = 16
Me!chkPDStatus.TabIndex = -1
End Sub

Error Message:

Run-time error '2184':
The value you used for the TabIndex propertiy isn't valid. The correct
valuses are from 0 through 4.

I have also tried to use DoCmd.GoToControl() Method on Exit event. It
worked, but I don't like the behavior when using a mouse.

Any help will be greatly appreciated.

Sincerely,
Raymond
 
D

Dirk Goldgar

How do I tab from a control on page 1 to a control on page 2 on a
TabControl? I have tried to set the TabIndexes manually on form load
but I get an error. See the following

Code:

Private Sub Form_Load()
Me!txtMake.TabIndex = 0
Me!txtModel.TabIndex = 1
Me!txtSerialNumber.TabIndex = 2
Me!txtExpressServiceCode.TabIndex = 3
Me!txtPurchaseDate.TabIndex = 4
Me!chkProduction.TabIndex = 5
Me!cmbPDLocationID.TabIndex = 6
Me!txtFunction.TabIndex = 7
Me!cmbCPUCount.TabIndex = 8 'Page one
Me!txtCPUSpeed.TabIndex = 9
Me!txtCPUType.TabIndex = 10
Me!txtRAMAmount.TabIndex = 11
Me!subArrays.TabIndex = 12
Me!txtOSInstalled.TabIndex = 13 'Page Two
Me!subInstalledSoftware.TabIndex = 14
Me!txtDNSName2.TabIndex = 15 'Page Three
Me!txtPrimaryIP.TabIndex = 16
Me!chkPDStatus.TabIndex = -1
End Sub

Error Message:

Run-time error '2184':
The value you used for the TabIndex propertiy isn't valid. The
correct valuses are from 0 through 4.

I have also tried to use DoCmd.GoToControl() Method on Exit event. It
worked, but I don't like the behavior when using a mouse.

Each tab page, like each section of a form, has its own tab order. The
following instructions were written with form sections in mind, but the
same approach works with tab pages. Just substitute "tab page" for
"section".

==========================
One way to handle this is to put an "infinitesimal" text box in each
of the sections, last in the tab order in its section. These text
boxes must have their Visible properties set to Yes, but their Height
and Width properties can be 0, rendering them effectively invisible.
You can also set BackStyle and BorderStyle to Transparent, and
SpecialEffect to Flat, just to make sure.

Then in the GotFocus event of each of these text boxes, set the focus
to the first normally visible control in the next section. This
effectively allows the use to tab forward out of the apparent last
control in a section and into the first control in the next section.

To handle back-tabbing, you would set up a corresponding set of text
boxes, placing them first in the tab order in their sections, and
transferring the focus from them to the last normally visible control
in the appropriate section. If you do this, you'll also need to set
the focus to one of the normally visible controls in the form's Load
event, so as to avoid having the focus start in one of the
inifinitesimal controls and thence be transferred where you don't want
it.
==========================
 
J

John Vinson

How do I tab from a control on page 1 to a control on page 2 on a
TabControl? I have tried to set the TabIndexes manually on form load
but I get an error. See the following

Each Tab Page has its own independent set of tab indexes. One thing
you can do - independent of the tab index of the Form, or of any
individual tab page - is to simply SetFocus to the desired control.
One trick is to put a textbox last in the tab order of Page 1; it
should be Enabled and Visible, but you can hide it behind another
textbox and/or make it just one twip square so the user can't click
into it. In its GotFocus event set the focus to the next control:

Private Sub txtRelayPage1_SetFocus()
Me!txtOSInstalled.SetFocus
End Sub

John W. Vinson[MVP]
 
Top