Results 1 to 5 of 5
  1. #1
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    List Pages in a Form (Access 2003/SP3)

    I'm trying to write a query that will list the pages in a form. But I can't find a method for referencing pages.

    any suggestions
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

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

    Re: List Pages in a Form (Access 2003/SP3)

    I'm afraid I don't understand - a query is based on one or more tables (or queries). How could it list pages in a form?
    And what exactly do you mean by pages in a form - as displayed on screen, or when printed on paper? And what would you want to list for the pages?

  3. #3
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: List Pages in a Form (Access 2003/SP3)

    I have a query that lists the forms in the db, now I'd like to be able to list the tab controls on each form and the pages within each tab control.
    I've been hunting around, and I think the only way to list the tab controls and pages with each is using a form.
    My rough plan now.
    Using a form: Have a combo box listing all the forms, when a form is selected in the combo box additional list boxes will display the tab control and pages for each tab control.

    The goal is to be able to find the page name.

    clear as mud I'm sure.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

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

    Re: List Pages in a Form (Access 2003/SP3)

    Your original post would have been clearer if you had mentioned tab controls and tab pages instead of just "pages".
    You will have to use VBA code to open a form in design view (this requires exclusive access to the database, it cannot be done with multiple users in the database). Then loop through the controls, and check whether it is a tab control. If so, loop through its Pages collection, and look at the Caption property.

  5. #5
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: List Pages in a Form (Access 2003/SP3)

    Thanks Hans for your help.
    After some consideration here is what I came up with as the code that I'm using behind the pictured form:

    Hope someone else finds this useful
    <pre>Option Base 1

    Private Sub cmbFormPicker_Click()
    Dim strFormName As String
    Dim iCounter As Integer
    Dim cntl As Control

    If lst_TabControls.ListCount > 0 Then
    iCounter = lst_TabControls.ListCount
    For iCounter = lst_TabControls.ListCount To 1 Step -1
    lst_TabControls.RemoveItem (0)
    Next iCounter
    End If
    iCounter = 0
    strFormName = Me.cmbFormPicker.Value
    DoCmd.OpenForm strFormName, acDesign
    For Each cntl In Forms(strFormName).Controls
    If cntl.ControlType = acPage Then
    Debug.Print "Name: " & cntl.Name & _
    " is a Page, with Caption: " & cntl.Caption
    iCounter = iCounter + 1
    lst_TabControls.AddItem cntl.Name
    End If
    Next cntl
    Debug.Print "There are " & iCounter & " Page tabs"

    DoCmd.Close acForm, strFormName, acSaveNo

    End Sub
    </pre>


    I fooled around with both the caption and name properties - discovering that I hadn't been that consistent with applying captions.
    Attached Images Attached Images
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Posting Permissions

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