Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Cedar Falls, Iowa, USA
    Posts
    268
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using active page on tab control for qry parameter (a2003)

    I have a tabbed control (tabctlAddresses) on a form (frmOrder) with 4 pages: pgHome, pgWork, pgShipTo and pgBillTo. Each page has the same fsubAddr.

    I want that subform to display the corresponding address, i.e. home address on pgHome, work address on pgWork, etc. If I can pass the OrgID from the main form and the page name of the active page on the control (minus the pg prefix) to the underlying query for the subform, that would do it, wouldn't it?

    The OrgID is the master/child link between the main form and the subform so that's taken care of. I'm stuck on how to use the name of the active page (minus the prefix) as the criteria for field strType.

    If this is a workable strategy, what's the best way to go about this?

    E

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: using active page on tab control for qry parameter (a2003)

    Are you saying that you have a single subform on the form and it shows up on each of the tab pages, or did you add the same subform 4 times, once to each page? In any case, you can't use the tab page as query criteria, although you can use the tab control value, which is the index of the active page.
    Charlotte

  3. #3
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: using active page on tab control for qry parameter (a2003)

    If I understand the form design correctly, the only easy way I see to do this is to add unbound textbox to form (hidden if necessary), with the following expression as ControlSource:

    =Mid$([TABCTL1].Pages([TABCTL1].Value).[Name],3)

    In this case TABCTL1 is name of Tab Control with the same subform on each page. The Mid$ expression acts to remove the "pg" prefix used to name the pages. The query that populates the subform has the following SQL:

    SELECT Table1.ID, Table1.Field1, Table1.Field2, Table1.Field3, Table1.Field4, Table1.Field5
    FROM Table1
    WHERE (((Table1.Field1)=[Forms]![frmTabs]![Text1]))
    ORDER BY Table1.ID;

    Where Field1 is the field that equates to Home, Work, etc., and Text1 is the unbound textbox described above. Use the Tab Control Change event to requery subform. Example:

    Private Sub TABCTL1_Change()

    With Me.TABCTL1
    Select Case .Value ' Tab index (zero-based)
    Case 0
    MsgBox "Name: " & .Pages(0).Name & vbCrLf & _
    "Caption: " & .Pages(0).Caption, vbInformation, "Page 1"
    Me.Subform1.Requery
    Case 1
    MsgBox "Name: " & .Pages(1).Name & vbCrLf & _
    "Caption: " & .Pages(1).Caption, vbInformation, "Page 2"
    Me.Subform2.Requery
    Case 2
    MsgBox "Name: " & .Pages(2).Name & vbCrLf & _
    "Caption: " & .Pages(2).Caption, vbInformation, "Page 3"
    Me.Subform3.Requery
    Case 3
    MsgBox "Name: " & .Pages(3).Name & vbCrLf & _
    "Caption: " & .Pages(3).Caption, vbInformation, "Page 4"
    Me.Subform4.Requery
    End Select
    End With

    End Sub

    Note: the msgboxes are for test purposes only (and get annoying fast), comment out or delete in actual use, just requery the applicable subform. Note that the Tab Control's Pages collection is zero-based, so what you think of as "Page 1" is actually Page 0, etc., as the test msgboxes demonstrate.

    HTH

Posting Permissions

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