Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2010
    Posts
    3

    Exclamation Unanswered: Getrows method not working

    Sub Test()

    Dim myrset As Recordset

    Dim temp As Variant

    Set myrset = CurrentDb.OpenRecordset("SELECT * FROM Holidays;")

    temp = myrset.GetRows(myrset.RecordCount)

    MsgBox UBound(temp)

    End Sub



    I also tried with including the patrol (myrset.movelast and myrset.movefirst) before accessing the recordcount. Still its giving the UBound 0. But Recordcount is 2.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    Try:
    Code:
    Set myrset = CurrentDb.OpenRecordset("SELECT * FROM Holidays;")
    myrset.MoveLast
    myrset.MoveFisrt
    temp = myrset.GetRows(myrset.RecordCount)
    MsgBox UBound(temp, 2)
    Have a nice day!

  3. #3
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Its a single statement:

    Code:
    recCount = Dcount("*","Holidays")

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by ranman256 View Post
    Its a single statement:

    Code:
    recCount = Dcount("*","Holidays")
    In reading this my first thought, like ranman256, was why you were going through all of this to get a RecordCount, instread of doing a simple DCount(); is that not your objective, here?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Jan 2010
    Posts
    3

    Question How to pass only a single dimension of an array?

    Hi all,

    Thank you for your answers. Now the getrows is working fine at my end. Now I have a different problem at hand:



    Sub Test2()

    Dim myrset As Recordset

    Set myrset = CurrentDb.OpenRecordset("SELECT * FROM Holidays;")

    myrset.MoveLast

    myrset.MoveFirst

    MsgBox myrset.RecordCount

    MsgBox excel.Application.WorksheetFunction.Networkdays(#8/1/2014#, #8/31/2014#, Array(#8/15/2014#, #8/29/2014#))

    MsgBox excel.Application.WorksheetFunction.Networkdays(#8/1/2014#, #8/31/2014#, excel.Application.WorksheetFunction.Index(myrset.G etRows(myrset.RecordCount), 0, 1))

    End Sub



    Recordcount is coming fine

    Manual Array is also giving the right result

    But the Index method is giving the wrong value. Why?



    (Holidays table is just having the values in the array only ie. #08/15/2014# and #08/29/2014#)

Tags for this Thread

Posting Permissions

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