Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / February 2005



Tip: Looking for answers? Try searching our database.

Do While not EOF looping through recordset twice.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 24 Feb 2005 23:22 GMT
I've created an ADO recordset,at run-time, to hold VAccess configuration
settings.  I step through the values and update them after each loop.

All works well until I try to update a sort order value using a loop
statement in another function used after the initial loading of the table.

What I am trying to achive is the ability to reasign table names to a
VAccess array. eg. I have two tables. When I first load the tables into the
recordset, one table has a value of 0 and the other has a value of 1.  When
the user selects a sorting column in my lookup, the function is to loop
through this record set and replace each 0 with a 1 and each 1 with a 0.  I
then reasign the VAccess table names with VAccess(0) having the table
assigned to the table name in the record with the sort of 0.

My problem is that the loop does not stop at EOF as expected.  It loops 4
time for these two records.  Here is my code:
With rsTable
.MoveFirst
Do While Not .EOF
.Fields("IndexNumber") = IIF(.Fields("IndexNumber") = 0 ,1, 0)
.Update
.MoveNext
Loop

As you can see, this is straight forward code.  I've shut down my
workstation to be sure that something was not remaining in memory that
shouldn't be there and I still have the same problem.

If I stop my code at run-time and step through this loop and not allow it to
run past the 2 tables, the rest of my code works as expected.

Is there something that I am not seeing with regards to update, movenext
with an ado recordset? Am I breaking some rules?

I look forward to any ideas or help.

Don
Val Mazur - 26 Feb 2005 02:14 GMT
Hi Don,

Are you using any events for you recordset? In a case if you do, it is
possible that something inside of those events could move pointer inside of
the recordset to the previous record Actually your code could look like (you
do not need IIF and it will work faster)

Fields("IndexNumber") = 1-.Fields("IndexNumber")

Signature

Val Mazur
Microsoft MVP

http://xport.mvps.org

> I've created an ADO recordset,at run-time, to hold VAccess configuration
> settings.  I step through the values and update them after each loop.
[quoted text clipped - 37 lines]
>
> Don
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.