Problems with .TabIndex

evanscamman

Registered User.
Local time
Today, 00:57
Joined
Feb 25, 2007
Messages
274
I am trying to assign .tabindex to controls in my form.

Immediately after I assign a control a number, it will randomly assign itself a different number.

I also tried setting the order backwards, with the same result.

For example:

Control14.tabindex = 13
Control13.tabindex = 12
Control12.tabindex = 11

debug.print control14.tabindex
7

debug.print control13.tabindex
11

debug.print control12.tabindex
12


Is the tabindex property just unreliable?
I have messed with this for 4 hours, and can't get it to work!!!

Please help,

Evan
 
Last edited:
Why are you doing this in code? You can open the form, select View > Tab Order and drag and drop into the correct order.
 
Why I need code

On a different page, the user selects which of 14 controls will be visible, and which order they will be in.
Each time the form loads, it has to hide/show each control, and position in correct order (predetermined by user). This changes all the time, so I need to be able to reassign the tab order.

Evan
 
You will have to set the tab order for ALL of the controls, regardless of whether they are hidden or showing.

Quote from the Access Help File
...In Form view, invisible or disabled controls remain in the tab order but are skipped when you press the TAB key.

You might also want to preface each control by using the ME keyword

Quote from the Microsoft Help File
TabIndex Property Example

The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.
Code:
Sub Form_Click()
    Me!Command1.TabIndex = 0
    Me!TextBox1.TabIndex = 1
End Sub
 
I was not setting the order for the invisible controls. I will try this.
Do you recommend setting order in reverse?
 
I guess you try it one way and if it works, don't worry about it. If not, try it the opposite way.
 
Still doesn't work

I have tried again and again starting frontwards and backwards.
Immediately after assigning the tabindex to a field, it invents its own number for itself.

For example:

Field1.tabindex = 23
debug.print field1.tabindex
7

next time it's different:

Field1.tabindex = 23
debug.print field1.tabindex
21

It appears to be totally random, and I have tried every combination of starting from the beginning or end, including or not including invisible fields.

This is extremely frustration!

I am beginning to believe that the .tabindex property in MS Access 2003 is just buggy!

Evan
 
have you tried going through all of them first and then checking afterwards? It is true (in all versions) that if you change one it renumbers based on the order they were entered on the form. Anyway, I wish you well on this as it's a pretty hefty job to make such user variable forms available.
 
Yes, I have gone through every control can that be assigned a tabindex, from top to bottom, or from bottom to top.
By the time I get to the end they are so messed up it doesn't make sense.
So I put a watch on every single field's tabindex.
Generally by the time I have changed the 2nd field, the 1st one has reset itself randomly. However, more of the time, the 2nd and 1st field will both have a different number immediately after being assigned one.

I wonder if it is the combination of fields I have that is causing this.

I have a tab control with 3 pages.
Page 2 has 35 controls and 1 frame (which I'm using just as a box, not as a control)
It works fine - the tab order stays.

Page 3 has 23 controls with a tabindex - 8 buttons, 2 frames (used just as boxes) - the rest are text and combo boxes & 2 check boxes.

This is the page that is having the problem - but the bug may only show up when setting the tabindex of controls that are on a page - if there is a certain combination of controls.

Very bizarre. I suppose I will try making a new page in a new file, and adding controls 1 at a time until i see which one causes the problem... :(
 
Solution (more of a work-around)

I tried to recreate the problem in another database, but couldn't duplicate the it.

So, I gave up trying to set the .tabindex altogether,
and used the Form_KeyDown event to intercept the TAB and Shift-TAB keys,
and start a subroutine that sends a .SetFocus to the appropiate field.

Not the most elegant solution, I'm sure, but it works.

Thanks for the help - I am now convinced that the .tabindex property is buggy in certain situations.

Evan
 
I've had similar problems with tabindex and I put it down entering tabIndex's that already exist

so if you have tabIndexes 1-3 and change 2 to 1 and 1 already exists I think Access reassigns the tab index but does'nt infor you so by the time you have been through all 50 controls the tab order is all messed up again
 
I think that the tabindex is buggy when the controls are nested inside a tab control. This is the only time I have had this problem.

Evan
 

Users who are viewing this thread

Back
Top Bottom