A single textbox to filter 3 unrelated subforms

Danick

Registered User.
Local time
Today, 14:04
Joined
Sep 23, 2008
Messages
377
I have a main form with three un-related subforms. Each subform shows data from its specific table.

Is there a way to create a single unassigned text box filter on the main form that will filter each of the subforms at the same time?
 
Hi. Sure. You can either use code to filter the subforms or maybe take advantage of the Linked Master/Child Fields properties to do it.
 
Hi. Sure. You can either use code to filter the subforms or maybe take advantage of the Linked Master/Child Fields properties to do it.

OK - well here is what I have so which works fine for filtering the first subform called "subFormAttachmentQuickLinks" on the main form

Code:
'----------------
Me.RecordSource = "SELECT * from tblAttachmentsQuickLinks; "
'-------------------
strWhere = ""

    'Document Name Filter
    If Not IsNull(Me.txtFilter) Then
    strWhere = strWhere & "(AttachmentName LIKE '*" & Me!txtFilter & "*') OR "
    End If
    
     'Document Path Filter
    If Not IsNull(Me.txtFilter) Then
    strWhere = strWhere & "(AttachmentFilePath LIKE '*" & Me!txtFilter & "*') OR "
    End If

'more code for choping off training end folder, ...


    Me.subFormAttachmentQuickLinks.Form.Filter = strWhere
    Me.subFormAttachmentQuickLinks.Form.FilterOn = True

What do I have to do in order to use the same filter button to also be able to filter a form "subFormAttachmentQuickLinks2" which has the record source "tblAttachmentsQuickLinks2"?
 
Hi. Just repeat the same code except use the names of the other subforms. For example:


Me.Subform1... = ...
Me.Subform2... = ...
Me.Subform3... = ...
 
Hi. Just repeat the same code except use the names of the other subforms. For example:


Me.Subform1... = ...
Me.Subform2... = ...
Me.Subform3... = ...

Thanks - that was it. I guess I wast thinking more complicated than it really was. Even seems to work fine if I remove the record source. Not sure why though. Still testing....
 
Hi. You're welcome. Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom