Setting TabIndex causes chaos

  • Thread starter Thread starter MSJohn
  • Start date Start date
M

MSJohn

I have an Access form with a TabControl object containing 4 pages.
I have set the tab order for the controls during design time.
This works fine. Now I want to change the tab order for one
of the pages at runtime at certain events.

However when I change the TabIndex settings for the objects, the
result is chaotic in that I can't see a pattern as to what the
new tab order is.

I verify that the TabIndex property values that I changed does actually
get changed, so I'm not sure what is going on.

I did a test where I just change one Textbox TabIndex to 0 and
initial focus does not go there, plus the tab order for all the
other objects is again chaotic.

Am I missing something?
 
MSJohn
Each individual tab must be TabOrdered individually... *while that tab is selected*.
Select one tab, then open the tab order dialog and arrange the sequence.
Select the next tab, and do the same.
If you don't select each tab before ordering, you'll get the chaos yo spoke of...
 
I'm not sure if I was clear, but I'm trying to change the tab order from
Visual Basic. e.g.
Textbox1.TabIndex= 0
Textbox2.TabIndex= 1

I can set the tab order at design time and that works OK. It's only
when I attempt the above that I have problem of chaos.
 
What does "chaos" mean?

I've never had occasion to reorder the pages at runtime, so just tried with
a simple unbound form and a tab control with 3 pages. Access allows you to
assign a value to the PageIndex of a page, and that page responds correctly.
The side-effect seems to be that the other pages are renumbered for you, to
accommodate the change you just assigned, i.e. if you change your 3rd tab
page to PageIndex 0, the one that had 0 becomes 1, and the one that was 1
becomes 2.

Is that what you observe? It kinda makes sense if you think of Access as
managing the tab pages to ensure they each have a unique index.
 
As I originally posted (see below) "chaos" meaning that after I set
the TabIndex values, the result is not what I specified nor can I
see a pattern as to what Access actually responds to tab input.

I change the TabIndex values for the page with PageIndex=1. It does not
affect the design-time TabIndex settings for the other 3 pages.
Each TabIndex page has their own unique "Tab Order" since I
can see the values at runtime using the debugger.
 
Okay, John.

The properties you set at runtime are generally not saved unless you switch
the form to design view. For example, if you code:
Me.Text0.DefaultValue = "New York"
that Default Value applies only while the form is open. It is not saved as a
design change, you don't have that Default Value for Text0 next time you
open the form.

It would be possible to write the the values you want to a table in
Form_Unload, and then assign them again in Form_Open.
 
My issue is not having the runtime changed value be saved. I just
want it to change during runtime. The problem is that the TabIndex
values that I set work, which it doesn't.
 
Okay, John, I'll leave it at that, as I don't think there is anything I can
add to this thread.
 
Are you setting the tabindex in order, like your example?
i.e =0, =1, =2 .....
obviously Access should increment all tabindexes >= to the last changed. You
change 3, the old 3 becomes 4, the old 4 becomes 5

wanttobe9.tabindex = 0
wanttobe8.tabindex = 0
wanttobe7.tabindex = 0
etc should work too.
 
Yes, I do set the TabIndex in order, primarily for ease of debugging.

So I tried an experiment. In my VB code I duplicated the order that
I set with "Design View". It worked correctly. I switch the order
of only two objects and they all go out of order!
 
Back
Top