By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Scan for each matched record

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
Nov 12 '05 #2

P: n/a
Hi Steve

Thanks for reply. Do i need to loop the SQL statement ? THanks.

Daniel


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.