PDA

Click to See Complete Forum and Search --> : ADO - MoveFirst,MoveNext not working


Pallex
Feb 3rd, 2000, 06:19 PM
I wonder if anyone can help with i think could be an easy problem for a non-beginner!

Facts
-----
I have 3 records: a,b,c.
I added them using the app i am having the problem with (so it opens, saves, closes correctly).
Access 2000 shows all 3 records correctly. I added the records in the order a,c,b.
I`m using vb6.0.

This is how i open the database:

cnEmployeesDataBase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & EmpDataBaseFile
cnEmployeesDataBase.Open

(jet 4.0 as its an access 2000 database)

This is how i open the recordset :

tempStr = "select * from Employees order by Surname"
rsEmployees.Open tempStr, cnEmployeesDataBase, adOpenKeyset, adLockOptimistic

(i believe i need the adOpenKeyset to get the `cursor access` (ability to navigate records) that i require)

To get to the record i want, i am using the following code

rsEmployees.MoveFirst

Do While rec > 0
rsEmployees.MoveNext
rec = rec - 1
Loop

I always get the same record - the last one - c (last in that its ordered by surname).

Can anyone explain why i get the last record all the time? Why isnt MoveFirst working properly? And isnt there a way to just move to record n anyway? I saw some code for a method where you passed 2 params - the record offset you wanted, and a `magic number` representing the first/last record, but i think this was for DAO. Anyway, i tried it, with exactly the same results.

Please help!!

Thank you,
Alex.

Pallex
Feb 3rd, 2000, 07:23 PM
Fixed it! sorry! i was fixing another bug, and, and my debug routines leave the recordset in that state, undoing the move, which was working properly all along!

Alex.