Results 1 to 4 of 4
  1. #1
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694

    GetRows() returning one record only

    all,



    I am inexperienced with this function. I have this partial code:
    Code:
    Function CrossFinance(tblName As String, typeData As String)
    
    On Error GoTo ErrorHandler
    
    Dim rsCol As Long
    Dim rsRow As Long
    Dim varRecs() As Variant
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset(tblName, dbOpenDynaset)
    
       'Get Table Data
       varRecs = rs.GetRows(rs.RecordCount)
    
    rs.MoveLast
    rs.MoveFirst
    
    For rsCol = LBound(varRecs(), 1) To UBound(varRecs(), 1)
       For rsRow = LBound(varRecs(), 2) To UBound(varRecs(), 2)
          Debug.Print "Field " & CStr(rsCol) & ", Row " & CStr(rsRow)
       Next rsRow
    Next fldCtr
    
    GoTo ErrorHandler
    There are 3 records in the table. What I dont' understand is why it's outputting this:



    I've tried importing to a new file and still does same thing. I've checked import report for both the module and the table. No dice. I've also tried running the loop without the move methods above it. The help file example does not use this process of opening the whole table before getting rows. What could be the problem? Any help appreciated! Thanks!

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Nevermind! Sorry about this. Solution is:
    Code:
    Set db = CurrentDb
    Set rs = db.OpenRecordset(tblName, dbOpenDynaset)
    'Set tblDef = db.CreateTableDef(tblName & "_TRANSFORM")
    
    rs.MoveLast
    rs.MoveFirst
    
       'Get Table Data 
       varRecs = rs.GetRows(rs.RecordCount)
       rsCol = 1
       rsRow = 0
    I guess what should be noted though is that MS says the following is supposed to get all the rows, but it doesn't for me:
    Code:
    Set db = CurrentDb
    Set rs = db.OpenRecordset(tblName, dbOpenDynaset)
    'Set tblDef = db.CreateTableDef(tblName & "_TRANSFORM")
    
    rs.MoveLast
    rs.MoveFirst
    
       'Get Table Data 
       varRecs = rs.GetRows()
       rsCol = 1
       rsRow = 0
    MS says in help file that omitting the arg returns all rows. it only returned one for me.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So Adam, is this thread Solved?

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by RuralGuy View Post
    So Adam, is this thread Solved?
    sorry Allen. Slip of the brain. thank you for the reminder.

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

Similar Threads

  1. Combo box returning only about 1000 records
    By cjbuechler in forum Forms
    Replies: 12
    Last Post: 06-30-2010, 08:27 AM
  2. Query not returning all of the results
    By velvettiger in forum Queries
    Replies: 4
    Last Post: 03-11-2010, 06:56 AM
  3. GetRows - Invalid Use of Nulls
    By Wannabe_Pro in forum Programming
    Replies: 3
    Last Post: 07-22-2009, 07:07 AM
  4. DMax returning wrong value
    By nedbenj in forum Access
    Replies: 7
    Last Post: 10-24-2007, 10:30 AM
  5. Calling a function and returning a value
    By 3dmgirl in forum Programming
    Replies: 0
    Last Post: 04-23-2007, 02:20 PM

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