Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selectively hide form header of tabbed form

Status
Not open for further replies.

Dom606

IS-IT--Management
Jul 29, 2007
123
US
I have a tabbed form with 5 tabs. The Header section on the main form shows the employee name. Only the first three tabs relate to individual employee data. The other two tabs display list of command buttons for reports, etc.

What I am trying to do is have the employee name in the header appear on the first three tabs. However, when either of the remaining tabs are clicked, I want the employee name field not to be visible.

I have tried putting this code on the “ON CLICK” event of one of the tabs that when selected would set the visible property to False.

=[Auto_Title0].[Visible]=False
[Auto_Title0].Visible]=False

My question is do I have the code in the correct place? If not, where should it go?
 
G'day Dom,

Too easy mate, On the OnChange event of the tab control :)

JB
 
Hi JB,
There is no OnChange event on the tab control. There is on click and I tried that but it did not work. Access 2007
Dom
 
JB, The control for the tab does not have a OnChange property (access 2007).
 
I dont have 2007 on this pc but i'd be shocked if they'd removed this property.

When you pull up the property sheet you'll notice a combo at the top. what does that say in it? if it's something like Pagex then drop down the list and choose something like TabCtlx

If it's really gone then my apoogies, I just know from past experience this one is tougher to find than most cos it depends how you select the control

jb
 
The drop down shows all the fields on the form. There is no TabCtlx or Pagex. I don't understand why the OnClick event does not do the trick. Oh well. Thanks for you help.
 
I have not looked at A2007 yet, but I am going to bet that JB is correct and the onChange event of the tab control still exists. Eventhough Acess 2007 sounds horrible, I have not heard mention of changing the native controls. The on click event of a tab control does not function the way one would expect. It does not fire every time you click on a tab. The normal trick to determine the clicked page is to return the value of the tab control in the on change event. The on change event occurs everytime a tab is switched, because the value of the control is the page index.

dim pageNumber as integer
pageNumber = me.tabcontrol.value

now you can use this as an index

me.tabcontrol.pages(pageNumber)

The pages are zero indexed

 
MajP,

Cheers mate, i was sat here scratching head thinking "wtf? Am I being really stupid here?!"

But I know the tab control itself is difficult to select rather than a page.

If 2007 has some new control that we don't know about at least I wont be alone in looking sheepish! I know you're a power guru so I feel less insecure now.

Have a great weekend, and Dom, best of luck sorting it out. Sorry my current installation doesn't allow me to help further, let me know when you get it sorted 'k?

JB
 
Hi Guys, I did some more research and got it to work with this code:

Code:
Private Sub tabEmployees_Change()
Select Case tabEmployees.Value ' which page was selected
    Case 0 ' first page, it's the zero-based Index property of the tab
        Me.Auto_Title0.Visible = True
    Case 1 ' second page
        Me.Auto_Title0.Visible = True
    Case 2 ' second page
        Me.Auto_Title0.Visible = True
    Case 3 ' second page
        Me.Auto_Title0.Visible = True
    Case 4 ' second page
        Me.Auto_Title0.Visible = False
    Case 5 ' second page
        Me.Auto_Title0.Visible = False
    Case 6 ' second page
        Me.Auto_Title0.Visible = False

End Select
End Sub

Thanks for all your help.
Dom
 
Good on ya mate!

but:
Code:
Private Sub tabEmployees_Change()

   me!Auto_Title0.visible=me!tabemployees < 4 

End Sub

is a little shorter :)

JB
 
To see why the click event does not work, try this


Private Sub TabCtl0_Click()
MsgBox "Click"
End Sub

You will see the only way to do this is to click on the very outside of the control. That is because the tab control is a container that has page objects within it. Everything on the inside is a Page that sits on top of the tabcontrol. So when you are clicking a tab you are not clicking on a tabcontrol but on a page.

Now each page object also has its own events so on page 2

Private Sub Page2_Click()
MsgBox "page 2 click"
End Sub

Now if you clicked inside on page 2 only you would get a message.

That is why we use on change instead of click. You could however put events on each page, it would just be more work.
 
Thank you guys. It has been a good education for me.
Dom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top