I have an active recordset (created with an SQL statement) & I wish to use recordset.filte r inside a loop, as each time I traverse the loop I want to filter for something different. How can I do this?
How do I use Recordset.filter inside a loop
Collapse
X
-
I don't know if that is doable, and whether you actually get any benefit from it. Another approach could be (Assuming you use DAO recordset which you forgot to specify) too use the FindFirst and FindNext methods
Code:Dim rs as Dao.Recordset set rs=currentdb.openRecordset...... Dim strFilter as string strFilter="ID_Author=" & 1 rs.FindFirst strFilter Do While not rs.Nomatch 'Your other code goes here rs.FindNext strFitler Loop
-
The Filter property applies to the recordset as opened Deb. It isn't something you can change mid-stream without requerying the recordset.
Can you make your question clearer please, as it's hard to answer when you have to spend so much energy guessing what the question is really saying.Comment
-
If it seems that way to you then I would suggest you don't have the experience to realise that we get thousands of requests for help which are not based on very sound logic or the most basic of understanding of the issues. Making assumptions about what the OP means is not generally a wise thing to do.
It is never sensible to ask questions without the purport of the question being made clear and explicit. That is why the site rules insist they are done in a way that doesn't waste everyone's time and energy responding with questions about what is actually meant.
I must admit that was always clear and obvious to me, but it's true that many need to go through the experience a few times before they realise why such questions are such a problem. In the mean time, we moderators are here to put people straight.
Thanks for your input.
PS. Clearly, in this case, to follow the implied logic of the question would be pretty silly indeed. I can imagine situations where that may be required, but none where that approach would make good sense. To advise in a case like this I'd need a proper understanding of what the OP thought she was asking about.Last edited by NeoPa; Apr 12 '13, 07:47 PM.Comment
-
Thanks for your reply. I found a solution by approaching the problem differently. As it was some time ago, I haven't got the details.I hope I haven't wasted anyone's time. I'm knew to posting stuff to forums.
I refer to this site a lot for help with Access VBA problems & find it most helpful. Keep up the great work.Comment
Comment