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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtered Records...I only want those

Status
Not open for further replies.

mission2java

Programmer
Jul 3, 2001
129
US
Simple problem..
main form .. sub form...
I filter by right clicking in the sub form field and select "Filter By Selection" now I click a button to just loop through the FILTERED recordset..but it keeps showing me all the records..I just want the FILTERED records on the screen.

Set db = CurrentDb

strSQL = "SELECT * FROM Table1 WHERE '" & Forms!Form1!frmSubForm.Form.Filter & "'"


Set rs = db.OpenRecordset(strSQL)

If rs.BOF Then
'do nothing
Else
While Not rs.EOF
MsgBox rs("First").Value
rs.MoveNext
Wend
End If

This does not work

Anyone?????

Jon

 
In the immediate window it shows:
?strSQL
SELECT * FROM Table1 WHERE '(([Table1 subform].Hobby="Baseball"))'

Which goes through..but it displays all the records..not just the filtered ones...

jon
 
I think the problem could be the quotes you've got around the WHERE clause ?
ie use:
strSQL = "SELECT * FROM Table1 WHERE " & Forms!Form1!frmSubForm.Form.Filter
 
IF I dont have the quotes it says "expected 1" and errors out.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top