Erratic Tab control Tab Tag Property (1 Viewer)

GK in the UK

Registered User.
Local time
Today, 20:46
Joined
Dec 20, 2017
Messages
274
OK struggling to get this one fixed.

A tab control with 6 pages. Ordinally numbered from 0 of course.

The OnChange event has a big ugly CASE select with some code that could be massively streamlined, but I need to get a value from each tab then drop it in a few places.

So I put some text in each of the tab tag property.

The tab pages have the Page Index property set as I expect, from 0 to 5, and each tab page has some text, two tabs that I'm currently coding have part of a sub form name.


After some experimentation I get the following consistent result:

Me.TabCtlIndexes.value - returns 0 to 5 as I expect

and

Me(Me.TabCtlIndexes.value).Tag - returns the tab tag text as I expect

So to get the tab tag text without the CASE statement seems to be with this construct:
Me(Me.TabCtlIndexes.value).Tag - which works, sort of

I know there is a difference of 1 somewhere, mentioned in the MS documentation but that doesn't explain the weird results I'm getting

THE CORRECT ORDER of the tab tag text is as follows, from the 1st tab (0), then add 1 for the difference somewhere in there

(1) Templates
(2) Quotations
(3) Orders
(4) IndexDaybook
(5) Index Posted
(6) OrdersComp

After not getting the right results I popped in a MsgBox and I find that I'm getting:

Tag(0)
Tag(1) - Templates
Tag(2) - Quotations
Tag(3) - Orders
Tag(4) - IndexDaybook
Tag(5) -
Tag(6) - IndexPosted

With an empty Tag(5).

Thinking it must be corruption of some kind, I deleted the tab control with its sub forms, de-compiled and rebuilt it.

The tab control has been rebuilt in the same order, all numbered as you would expect.

Now I get

Tag(0)
Tag(1)
Tag(2)
Tag(3) - Templates
Tag(4) - Quotations
Tag(5) - Orders
Tag(6) - ThIndexDaybook


What is going on ?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:46
Joined
Oct 29, 2018
Messages
21,454
Hi. To better understand your situation, are you able to post a sample db demonstrating this problem? To be honest, I don't understand this syntax: Me(Me.TabCtlIndexes.value).Tag
 

GK in the UK

Registered User.
Local time
Today, 20:46
Joined
Dec 20, 2017
Messages
274
There's not a lot of info out there about how to get the tab tag name so my construct was a guess really after using AutoFill to get the right controls.

the line
Select Case Me.TabCtlIndexes.value
is what I've had in all along, each case select has some repetitive code but I need to put a string variable in there, that's coming from the tab tag. It ought to work without the Case Select at all.

Per FMS and good practice, rather than use Case 0 etc. I changed the Case values to
Case pTemplates.PageIndex
Case pQuotes.PageIndex
etc.

and that's worked fine

Then I discovered that
Me.pDaybook.Tag returns 'IndexDaybook' so I'm on to something. pDaybook is one of the tab page names and is offered by by AutoFill after typing me.

So I think if I replace pDaybook part with Me.TabCtlIndexes.value I should get the tab tag text for each tab without the CASE select.

So I find that Access is happy with
Me(Me.TabCtlIndexes.value).Tag

And I get a result for each tab tag text, but the order is erratic.

I should be able to replace the entire Case Select with that function (I think)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:46
Joined
Oct 29, 2018
Messages
21,454
Hi. I really can't understand what you're saying because I can't see what you're looking at. The syntax Me.TabControlName should return the value of the tab control, which would be the currently active tab page. If you want to know the name of that tab page, then you can use something like: Me.TabControlName.Pages(Me.TabControlName).Name, but if you want to know the Tag property of the page, then you could try: Me.TabControlName.Pages(Me.TabControlName).Tag
 

GK in the UK

Registered User.
Local time
Today, 20:46
Joined
Dec 20, 2017
Messages
274
but if you want to know the Tag property of the page, then you could try: Me.TabControlName.Pages(Me.TabControlName).Tag
And that did it ! Wish I'd asked sooner.


Thanks so much.


Might have another question coming up about how to drop that result in a query / file name string, I'll see how it goes
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:46
Joined
Oct 29, 2018
Messages
21,454
And that did it ! Wish I'd asked sooner.

Thanks so much.

Might have another question coming up about how to drop that result in a query / file name string, I'll see how it goes
Hi. Glad to hear that worked for you. If you had posted your full code earlier, I might have been able to understand you better. But luckily, things worked out this time. Good luck!
 

Users who are viewing this thread

Top Bottom