Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2006
    Location
    Melbourne, Victoria, Australia
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    page caption on tab control (2003)

    Hi all,
    I would like to have a text box on a form into which the user types the name of a research project (ie. traumatic brain injury). I would like this text to then show as the page caption on a tab control. This way, as research projects change, the captions also change. The tab conrols is used as an appointment book. Is this possible?
    Thanks,
    Van

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: page caption on tab control (2003)

    A tab control usually has several pages. For which page do you want to set the caption?

  3. #3
    2 Star Lounger
    Join Date
    Oct 2006
    Location
    Melbourne, Victoria, Australia
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: page caption on tab control (2003)

    Hi Hans,
    I envision 3 or 4 pages.....each with a separte caption (I would have say 3 or 4 unbound text boxes which would hold the text for each caption).
    Regards,
    Van

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: page caption on tab control (2003)

    I would create a small table tblCaptions with 2 fields:

    Index (number, long integer, primary key).
    Caption (text)

    Each record in this table describes the caption for a tab page:

    <table border=1><td>Index</td><td>Caption</td><td align=right>0</td><td>Diabetes Mellitus</td><td align=right>1</td><td>Traumatic Brain Injury</td><td align=right>2</td><td>Asthmatic Bronchitis</td></table>
    Note that the first page has index 0.

    Next, create a small form in which the user can edit the table.

    Finally, add code to the On Open or On Load event of the form containing the tab control to set the captions:

    Private Sub Form_Load()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    On Error GoTo ErrHandler
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblCaptions", dbOpenDynaset)
    Do While Not rst.EOF
    Me.ctlTab.Pages(rst!Index).Caption = rst!Caption
    rst.MoveNext
    Loop
    ExitHandler:
    On Error Resume Next
    rst.Close
    Set rst = Nothing
    Set dbs = Nothing
    Exit Sub
    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    The advantage of storing the captions in a table is that they persist between sessions, and that it's easy to add or remove records. Creating a text box for each tab page is harder to maintain.

  5. #5
    2 Star Lounger
    Join Date
    Oct 2006
    Location
    Melbourne, Victoria, Australia
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: page caption on tab control (2003)

    thanks muchly Hans.
    Regards, Van

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •