Filter Subform (1 Viewer)

rustyCrVx

The Post is a Lie
Local time
Today, 12:21
Joined
Aug 15, 2008
Messages
83
I have a main form (frmClientMasterSearchAdv) with several unbound controls that will be used to filter a subform (subfClientMasterSearch) listing a bunch of records from a sql query. The controls in the header of the main form create a string (strWhere) when the appropriate button is clicked in the header, which is then be applied to the subform's filter. The problem comes up when applying that filter to the subform. I must be referencing it wrong(?)

The error I get is:
Run-time error '2450'
...can't find the form 'subfClientMasterSearch' referred to in a macro expression or VB code.

Here's what I've got:

Code:
'************************************************************************
'Chop off the trailing " AND " and decide if there is any search criteria
'************************************************************************
    lngLen = Len(strWhere) - 5
    If lngLen <= 0 Then
        If MsgBox("List all records?", vbYesNo, "No Criteria") = vbYes Then
            [Forms]![subfClientMasterSearch].Visible = True
            [Forms]![subfClientMasterSearch].FilterOn = False
        Else
            [Forms]![subfClientMasterSearch].Filter = "(False)"
            [Forms]![subfClientMasterSearch].FilterOn = True
        End If
    Else
        strWhere = Left$(strWhere, lngLen)
        [Forms]![subfClientMasterSearch].Filter = strWhere
        [Forms]![subfClientMasterSearch].FilterOn = True
    End If
 

Steve R.

Retired
Local time
Today, 13:21
Joined
Jul 5, 2006
Messages
4,720
I don't think that you are correctly referencing the subform. In the sample below, the subform is held in the main form control "Child31".


Code:
Select Case Case2num 'Establish Filter
        Case 1 'No Selection Made.  Display all records.
            Me!Child31.Form.FilterOn = False
            Me.Text17.Value = DCount("*", "projectnumqry")
            FilterNamestr = ""
            Me.Child31.Width = SubFormWidthint
        Case 2 'Selection Made.  Display Records through filter.
            Me!Child31.Form.Filter = FilterNamestr
            Me!Child31.Form.FilterOn = True
            Me.Text17.Value = DCount("*", "consistency", FilterNamestr)
            If Me.Text17 <= 34 Then
                    Rem the value 240 is a manually derived adjustment have not figure out how to do it using the various width properties.
                    Me.Child31.Width = SubFormWidthint - 240
                Else
                    Me.Child31.Width = SubFormWidthint
                End If
        Case Else 'No Matching Case Number
            MSG1 = "No matching case statement found.  Check the code in Case2num. Case2num = " & Case2num
            TITLE1 = "Select Statement Error"
            MsgBox MSG1, vbOKOnly, TITLE1
    End Select
 

rustyCrVx

The Post is a Lie
Local time
Today, 12:21
Joined
Aug 15, 2008
Messages
83
Yeah I just figured that out. I had received a different error when doing that because I had incorrectly set up string for the filter on the subform, but didn't really pay attention to it (too busy enjoying my Wendy's burger). I appreciate the fast reply.:eek:
 

Users who are viewing this thread

Top Bottom