Results 1 to 4 of 4
  1. #1
    exhumed is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    6

    GetRows method problem

    Hi!
    I have the question about GetRows method. I have following table:

    column1 column2
    abc 10
    cde 20
    fgh 30

    the fragment of my code is:

    Dim rs_temp1 As ADODB.Recordset
    Set rs_temp1 = New ADODB.Recordset
    rs_temp1.Open "Table1", CurrentProject.Connection, adOpenKeyset, adLockPessimistic
    rs_temp1.Movefirst

    Dim x
    x = rs_temp1.GetRows(1, 0, 0)
    MsgBox x(0, 0)

    the result is "abc" and it is OK

    If I change the row number just like:
    x = rs_temp1.GetRows(1, 1, 0)
    the result is this same as above, so "abc" instead of "cde"
    Why it does not work correctly?


    thx in advanced

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you explain what you are trying to do with this, are you trying to load information into an array or just cycle through your recordset one record at a time, or are you trying to access data from multiple rows at once?

    If you're just trying to cycle through records you can do this:

    Code:
    Dim db As Database
    Dim rst As Recordset
    
    Set db = CurrentDb
    Set rst = db.OpenRecordset("Table1")
    rst.MoveFirst
    
    Do While rst.EOF <> True
        x = rst.Fields(0)
        Debug.Print x
        rst.MoveNext
    Loop
    
    db.Close
    EDIT when dealing with recordsets this way item 0 is actually the first column of data.

  3. #3
    exhumed is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    6
    THX a lot for the way you have shown me. It works
    Of course I can explain: I learn how to use GetRows method, so I gave only one example from my deeds. I tried to do this with Do Until...Loop but using GetRows method result was three times "abc"

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I don't follow your response. I have never used the getrows method because I work with very large datasets and getrows is just not efficient enough for me. I was offering a solution that works depending on what the rest of your code is doing. That's all

Please reply to this thread with any new information or opinions.

Similar Threads

  1. GetUser method
    By pkstormy in forum Code Repository
    Replies: 7
    Last Post: 11-22-2012, 06:00 PM
  2. Transferspreadsheet Method
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 11
    Last Post: 06-30-2011, 11:40 AM
  3. GetRows() returning one record only
    By ajetrumpet in forum Programming
    Replies: 3
    Last Post: 09-09-2010, 09:32 PM
  4. Which method is better?
    By undrcvr in forum Database Design
    Replies: 3
    Last Post: 05-24-2010, 12:46 PM
  5. GetRows - Invalid Use of Nulls
    By Wannabe_Pro in forum Programming
    Replies: 3
    Last Post: 07-22-2009, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums