Results 1 to 4 of 4
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    multiple subforms

    All; using 2010. I have a unbound search form with a subform. I want to add another subform. I am having trouble linking the subform to the main subform. Here's my code:



    Code:
    Private Function SearchFilter() As Variant
        Dim varWhere As Variant
        varWhere = Null  ' Main filter
        ' Check for LIKE Client Num
        If Me.txtClientID > "" Then
            varWhere = varWhere & "[client_num] LIKE """ & Me.txtClientNum& "*"" AND "
        End If
       '     Check for LIKE Description
        If Me.txtDesc > "" Then
            varWhere = varWhere & "[bus_name1] LIKE """ & Me.txtDesc & "*"" AND "
        End If
        ' Check for LIKE Company
        If Me.txtCOM > "" Then
            varWhere = varWhere & "[CO]LIKE """ & Me.txtCOM & "*"" AND "
        End If
        ' Check for State
        If Me.txtSTATE > "" Then
            varWhere = varWhere & "[state] LIKE """ & Me.txtSTATE & "*"" AND "
        End If
        ' Check if there is a filter to return...
        If IsNull(varWhere) Then
            varWhere = ""
        Else
            varWhere = "WHERE " & varWhere
       
        StringFilter = varWhere
        End Function
    This is my search button code:
    Code:
    Private Sub btnSearch_Click()
       
        ' Update the record source
        Me.frmsubClients.Form.RecordSource = "SELECT * FROM qryClientData " & SearchFilter
       
        ' Requery the subform
        Me.frmsubClients.Requery
    End Sub
    I want to have the second subform filter records based on the filtered main subform. Can I add code under the search button where I update the recordsource for the main subform? Just a thought. I have yet to make this work. Please help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Looks close. I can't see how this works. It says no master child link but it looks like there is one. Also; I don't see how the txtbox is working.

  4. #4
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Got it to work. Hopefully it will work with more than 2 subforms

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple Subforms with Related Data
    By funkymuppet in forum Forms
    Replies: 1
    Last Post: 04-01-2014, 08:40 PM
  2. Multiple subforms to one main form
    By mick3911 in forum Forms
    Replies: 8
    Last Post: 02-25-2013, 09:40 PM
  3. Tab index multiple subforms
    By TToc2u in forum Forms
    Replies: 3
    Last Post: 02-23-2013, 06:00 PM
  4. Form with multiple subforms, many prompts
    By funkstrong in forum Forms
    Replies: 2
    Last Post: 10-12-2011, 11:40 AM
  5. position multiple subforms
    By Mclaren in forum Programming
    Replies: 1
    Last Post: 07-12-2010, 08:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums