Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Subform from ComboBox

Status
Not open for further replies.

Ebes1099

Technical User
Jul 8, 2009
156
US
I'm having problems using a combo box to filter my subform. I must have something wrong in the code and I can't figure out what it is. I have a combo box with GroupNumbers in it, the box is named GrpNmbrBox. Then I create a string to put my SQL filter statement in. Then I try and reference my subform with Me.SubFormName.Form.RecordSource = StringFilter and I get an error.

It gives me an error, "The Record Source "here it has my SQL statement" based on this form does not exist"

Here's my code.

Code:
Private Sub GrpNmbrBox_AfterUpdate()
    Dim strFilter As String
    
    GrpName = DLookup("[GroupName]", "Claims Inputs", "GroupNumber=GrpNmbrBox")
    
    strFilter = "select * from Claims Inputs"
    strFilter = strFilter & " where GroupNumber = '" & Me.GrpNmbrBox & "'"
    
    Me.ManualMapSubform.Form.RecordSource = strFilter
    
End Sub

Claims Inputs is the name of the table. GroupNumber is the field in the table I want to filter by.
 
I forgot to mention that GroupNumber is a Text field, not a number field, that's why I have the single quotes in the SQL statement there.
 
Private Sub GrpNmbrBox_AfterUpdate()

Dim strFilter As String

strFilter = "SELECT Claims Inputs.* "
strFilter = strFilter & "FROM Claims Inputs "
strFilter = strFilter & "WHERE (((Claims Inputs.GroupNumber)='" & Me.GrpNmbrBox & "'" & "));"

Forms![MainFormNameHere]![ManualMapSubform].Form.RecordSource = strFilter

ManualMapSubform.Requery

End Sub

untested hth

HTH << MaZeWorX >> Remember amateurs built the ark - professionals built the Titanic [flush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top