How do I populate an array from a recordset ??

Results 1 to 3 of 3

Thread: How do I populate an array from a recordset ??

  1. #1
    jason Guest

    Default How do I populate an array from a recordset ??

    here is the code i am trying to use:<BR>``````````````````````````````````````<BR> dim localArray()<BR>i = 0<BR>redim preserve localArray(i)<BR>do until rsApps.EOF<BR> localArray(0)= rsApps(0)<BR> i = i+1<BR>loop<BR>`````````````````````````````````

  2. #2
    jason Guest

    Default the answer

    OK, I figured out my original problem, heres the code for anyone interested:<BR>``````````````````````````````````` ````<BR>dim recordcount<BR>dim arrayApps()<BR>recordcount = 0<BR>do until rsApps.EOF<BR>rsApps.MoveNext<BR>recordcount = recordcount + 1<BR>loop<BR>rsApps.movefirst<BR>redim arrayApps(recordcount)<BR>for i = 0 to recordcount-1<BR>arrayApps(i)= rsApps(0) & left(rsApps(2), 30)<BR>rsApps.movenext<BR>next<BR>items = arrayApps<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: the answer

    I think you could do without the loop if you are using a static<BR>cursor in your recordset. Says Microsoft (MSDN Library):<BR><BR>"The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source."<BR><BR>So, try using a static cursor and rs.RecordCount instead of the loop.<BR><BR>See also:<BR>

Posting Permissions

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