Rename Page on Tab Control

RevJeff

Registered User.
Local time
Yesterday, 19:42
Joined
Sep 18, 2002
Messages
127
Hi,

Is there a way of renaming a Page on a Tab Control through code? Like when you click a button, the name changes and when you click a different button, it changes back?

Thanks,

Jeff
 
The name or the caption?

Can you show us a screenshot of what you're talking about.
 
Ok, I attached a screenshot of what I am trying to change. I want the word "Login" to change to "Logout" and then back again by clicking different buttons.

Thanks!
 

Attachments

So that's the caption of a Page on the Tab control. To change it you can use this syntax:
Code:
Me.TabControlName.Pages("PageName").Caption = "Logout"
 
Thank you for all the help, but I am still having a problem. Below is the code I am using.

Me.TabCtl0.Pages("LoginPage").Caption = "Logout"

But I am getting the following error.

"Compile error: Method or data member not found" and ".TabCtl0" is highlighted.

Does it matter if the button is on a form that is on the Tab Control?

Thanks!
 
Where is this button located? The button where the code is placed.

And where is the tab control located?

Finally Rev. Jeff ;) , what event did you put the code?
 
Ok, thank you again for all of the help.

Ok, I will try to explain this as best as I can. The main form is called "frmSwitchBoard". On that form I have the Tab Control that is named "TabCtl0". On the page named "Login" I have a subform called "frmLogin". The button "Command10" resides on that form and the code is in "On Click" event.

Sorry for any confusion.
 
So to refer to the tab control you can use this syntax:
Code:
Me.[COLOR=Blue]Parent.[/COLOR]TabCtl0.Pages("LoginPage").Caption = "Logout"
The bit I added is in blue.
 
Ok, now I was getting the following error:

Run-time error '2467':

The expression you entered refers to an object that is closed or doesn't exist.

I played around with it and took out the quotes around "LoginPage"

Me.Parent.TabCtl0.Pages("LoginPage").Caption = "Logout"

Me.Parent.TabCtl0.Pages(LoginPage).Caption = "Logout"

And it works great!!

Thanks for all of your help and patience!
 
Happy to hear! :)

... but is LoginPage the name of a control that has a Number data type as its value?
 
That is the name of the page on the Tab Control.
 

Users who are viewing this thread

Back
Top Bottom