473,379 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How do I use Recordset.filter inside a loop

2
I have an active recordset (created with an SQL statement) & I wish to use recordset.filter inside a loop, as each time I traverse the loop I want to filter for something different. How can I do this?
Nov 1 '12 #1

✓ answered by TheSmileyCoder

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



Expand|Select|Wrap|Line Numbers
  1. Dim rs as Dao.Recordset
  2. set rs=currentdb.openRecordset......
  3. Dim strFilter as string
  4. strFilter="ID_Author=" & 1
  5.  
  6. rs.FindFirst strFilter
  7. Do While not rs.Nomatch
  8.   'Your other code goes here
  9.  
  10.   rs.FindNext strFitler
  11. Loop

6 3871
TheSmileyCoder
2,322 Expert Mod 2GB
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



Expand|Select|Wrap|Line Numbers
  1. Dim rs as Dao.Recordset
  2. set rs=currentdb.openRecordset......
  3. Dim strFilter as string
  4. strFilter="ID_Author=" & 1
  5.  
  6. rs.FindFirst strFilter
  7. Do While not rs.Nomatch
  8.   'Your other code goes here
  9.  
  10.   rs.FindNext strFitler
  11. Loop
Nov 1 '12 #2
NeoPa
32,556 Expert Mod 16PB
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.
Nov 1 '12 #3
***


Since Deb is talking about looping, seems to me the recordset would be requeried each time. That wasnt clear?
Apr 12 '13 #4
NeoPa
32,556 Expert Mod 16PB
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.
Apr 12 '13 #5
DebR
2
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.
Aug 16 '13 #6
zmbd
5,501 Expert Mod 4TB
DebR (...)As it was some time ago, I haven't got the details.(...)
No, DebR, you didn't waste anyone's time.

(...)
This is exactly why we discourage posting into old threads unless the post has something really special to add.
Aug 16 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Aggelos | last post by:
Hi Guys!!! Thanks in advance for any kind of help about this problem. The problem: Acces Database One Table 'Orders' and second 'OrderItems' I want to export in txt file using FSO and...
3
by: crispy | last post by:
Hello group, I'm again having trouble putting ASP records INSIDE html link. Here's the string I put inside Access field: No room number specified (<a...
4
by: Chris Oakleaf | last post by:
With the following code snippet: <%="complexid =" & rsComplex("ComplexID")%> <% rsPhoto.filter = "complexID =" & rsComplex("ComplexID") %> <%response.Write("<br>ID: " & rsPhoto("complexID"))%> ...
5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
2
by: MGFoster | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I want the recordset (rs) in the following function to be updateable. How do I do it? Even though the code is VBA I will be translating to VBS...
6
by: dpswissboy | last post by:
I have a form with 30 input boxes named box1, box2, box3, etc. Instead of: var1 = Request.Form("box1") var2 = Request.Form("box2") etc. ..I am trying to collect the values in a loop statement...
0
by: hmiller | last post by:
Hey Guys, I'm just playing around with a DB I wrote for work and trying to minize as much coding as possible. So two questions. 1. What are your standard practices for organizing your code...
1
by: hmiller | last post by:
Hey Guys, I'm just playing around with some code I wrote for work and am trying to minimize the coding as much as possible. So two questions: 1. What are your best practices for organizing...
1
by: Neekos | last post by:
how do i use Recordset.Filter to reference the current form? i tried using Set rst = New ADODB.Recordset rst.Open "tblPaxInfo", CurrentProject.Connection rst.Filter = "(= me!)...
3
by: fishnfrogs | last post by:
Hi, I can't figure out why this isn't working. I'm trying to loop through an array and do a mysql update. However, it doesn't work. for($i = 0; $i < $len; ++$i) { $param = $array . '%';...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.