Results 1 to 2 of 2

Thread: ADO - MoveFirst,MoveNext not working

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290

    Post

    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.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290

    Post

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width