Forms work best with recordsets based on queries, and searching for a set of
matches in a database is best done with a query of the database. Thus,
displaying a list of matches in a subform is best done by setting the form's
recordsource to the SQL for a query that finds and returns the rows in
quesiton.
strSQL = SELECT * FROM <mytable> WHERE " & fmonth & " And " & fyear
Me.RrecordSource = strSQL
On 3 Feb 2004 08:48:54 -0800,
da*******@time.net.my (Daniel Tan) wrote:
In my code, i tried to scan for each record in my database that
matched certain criteria and then display it in a subform. I used the
following codes but it will only display last record, i want to
display all records. Pls help. Thanks
Set rs = Me.Recordset.Clone
rs.FindFirst fmonth & " And " & fyear
Me.Bookmark = rs.Bookmark
Do Until rs.EOF
rs.FindNext fmonth & " or " & fyear
book = rs.Bookmark
rs.MoveNext
Loop
Me.Bookmark = book
Regads,
Daniel
The code you wrote does find each match, but then doesn't do anything with
each match when it finds it. At the end of the loop, it has found the last
match, then it sets the form's bookmark to point to that last row that it
found.