• Hiding Tabs (Access 2003)

    Author
    Topic
    #429475

    Hi, does anyone know if it is possible to hide tabs in a form if they are not needed for that type? eg. we have a form where three different types of information come into together and have one tab which shows the main information. We then have three extra tabs, one for each type. We would like to be able to only show the two tabs that are needed for each type, without creating seperate forms for each, is this possible?? Thanks

    Viewing 1 reply thread
    Author
    Replies
    • #1000340

      You can hide/unhide tab pages in code:

      Me.TabControl.Pages(2).Visible = False

      will hide the 3rd tab page (they are numbered starting with 0, so Pages(2) is the 3rd tab)

      • #1000343

        Thanks, where do i put this code??
        Thanks

        • #1000347

          Probably in the On Current event of the form, but you’ll have to provide more info if you want specific help.

    • #1000349

      Hi, i havent got an “on Current” event, what information would you need for further help?

      • #1000350

        How can we decide which tabs should be displayed, and when do you want this to happen? Please try to provide detailed and specific information.

        • #1000351

          i want the 1st & 2nd tab to be there but the 3rd & 4th not to be when i open the form if it is type 1;
          i want the 1st & 3rd tab to be there but the 2nd & 4th not to be when i open the form if it is type 2;
          i want the 1st & 4th tab to be there but the 2nd & 3rd not to be when i open the form if it is type 3;
          I would like this to happen as i open the form? Do you need to know what the types are/what the tabs are called? Thanks

          • #1000352

            > “… if it is type 1”

            How do I know if it is type 1, 2 or 3?

            • #1000354

              the field called “TRType” will be either type one type two or type three.

              Does that help?

            • #1000355

              And shouldn’t the visibility change as the user moves from record to record? Or is it impossible to move to another record?

            • #1000357

              yes we would like the visibility to change as that field changes between records if possible.

              Thanks

            • #1000359

              Proceed as follows:

              • Open the form in design view.
              • Activate the Event tab of the Properties window.
              • Click in the On Current event (it’s the first one).
              • Select [Event Procedure] from the dropdown list.
              • Click the … button to the right of the dropdown arrow.
              • The Visual Basic Editor will be activated, and you’ll see the following code:

                Private Sub Form_Current()

                End Sub

              • Make the code look like this:

                Private Sub Form_Current()
                Dim i As Integer
                For i = 1 To 3
                Me.TabControl.Pages(i).Visible = (Me.TRType = i)
                Next i
                End Sub

                Substitute the name of the tab control for TabControl. If the name contains spaces or punctuation, put square brackets around it, e.g.

                Me.[Tab Control].Pages(i).Visible = (Me.TRType = i)
              • Switch back to Access.
              • Close and save the form.
                [/list]Now open the form to test if the code works.
            • #1000394

              In addition to what HansV suggested, if your TRType field is on the tabbed form (presumably on one of the pages that is always visible), you’ll probably want to put the same code in the After Update event of the TRType field so when the type is entered the appropriate pages immediately disappear.

            • #1000398

              Good point! thumbup

            • #1000500

              Thank-you for the code, I can’t get it to work unfortunately, there is propably something I am missing, i am substituting the TabControl for the name of the Tab – ReturnTab do I have to substitute anything else? I dont know whether I am supposed to change the i??

            • #1000502

              I think we’d have to see the database to know what is wrong. Could you post a stripped down copy of your database? See post 401925 for instructions.

            • #1000507

              database attached

            • #1000510

              You haven’t created an On Current event procedure, so it’s not surprising that it doesn’t work. Please follow the instructions I posted higher up in this thread.

              By the way, removing ALL records from the tables is not a good idea – there is nothing to test.

            • #1000511

              i took the on current procedure out because it made the database crash – the records are confidential, i created some “test” ones and it made the file too big.

            • #1000516

              See attachment (13 KB zip file with Access 2000 format database, with some test records)

    Viewing 1 reply thread
    Reply To: Hiding Tabs (Access 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: