Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2010
    Posts
    1

    Unanswered: Filtering a subform with a combo box

    I have been trying to adapt a method to filter a sub form on a tab page in my master form with a combo box that is also on the tab page (not the main form).

    The subform lists all records for the field linking the subform to the master form but I want to filter these further by Species and Year;

    Private Sub ComboFilterSpp_AfterUpdate()
    Dim strwhere As String

    If IsNull(Me.ComboFilterSpp) = False Then strwhere = "(Species = " &
    Me.ComboFilterSpp & "')"
    End If

    If IsNull(Me.ComboFilterYear) = False Then

    If strwhere < "" Then
    strwhere = strwhere & " and "
    End If

    strwhere = "(Year = '" & Me.ComboFilterYear & "')"
    End If

    strwhere = "select * from Survey_Report_Query where " & strwhere

    Me.Survey_Report_Query_SF.Form.RecordSource = strwhere

    End Sub

    My combo boxes are ComboFilterSpp and ComboFilterYear, my sub form is
    Survey_Report_Query_SF and my underlying query is Survey_Report_Query.

    For some reason I am getting a compile error "Method or data member not
    found" when I call the subform.

    I suspect I may also be having numerical data issues since the field I am filtering by has an underlying numerical value.

    I would be greatly appreciative of any help you might give.

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    IsNull(Me.ComboFilterSpp) = False

    is incorrect syntax; should be:
    IsNull(Me.ComboFilterSpp)

    either it is or is not - no true or false

Tags for this Thread

Posting Permissions

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