Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Record set to array?

Is it possible to make a query using ado and have the data dumped into
an array for more manipulation? Right now I have a query like this:


strQuery = "SELECT baser, upt, multiplier FROM olb WHERE" & _
" SPR = '" & Range("C2").Value & "'" & _
" ORDER BY id desc"
With rs
.Open strQuery, dbConn, adOpenStatic
Range("J6").CopyFromRecordset rs
.Close

But I would rather do Array.Copyfromrecordset or something like that

The results of the query can be different sizes so I can't predefine
the array size, I think this requires declaring a variable as
'variant', but from there I'm not quite sure where to go.

Thanks for any assistance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Record set to array?

dim arrRecs as variant

arrRecs = rs.GetRows()

--
Tim Williams
Palo Alto, CA


"mazzarin" wrote in message ups.com...
Is it possible to make a query using ado and have the data dumped into
an array for more manipulation? Right now I have a query like this:


strQuery = "SELECT baser, upt, multiplier FROM olb WHERE" & _
" SPR = '" & Range("C2").Value & "'" & _
" ORDER BY id desc"
With rs
.Open strQuery, dbConn, adOpenStatic
Range("J6").CopyFromRecordset rs
.Close

But I would rather do Array.Copyfromrecordset or something like that

The results of the query can be different sizes so I can't predefine
the array size, I think this requires declaring a variable as
'variant', but from there I'm not quite sure where to go.

Thanks for any assistance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Record set to array?

Depending what you are trying to achieve, you can also manipulate the RS
(depending on the cursor)
With RS.
.MoveFirst
Do while not .EOF
.Fields(1).Value=.Fields(1).Value+2
.NoveNext
Loop

But it would be better to optimise your SQL to return the correct info in
the first place.

NickHK

"mazzarin" wrote in message
ups.com...
Is it possible to make a query using ado and have the data dumped into
an array for more manipulation? Right now I have a query like this:


strQuery = "SELECT baser, upt, multiplier FROM olb WHERE" & _
" SPR = '" & Range("C2").Value & "'" & _
" ORDER BY id desc"
With rs
.Open strQuery, dbConn, adOpenStatic
Range("J6").CopyFromRecordset rs
.Close

But I would rather do Array.Copyfromrecordset or something like that

The results of the query can be different sizes so I can't predefine
the array size, I think this requires declaring a variable as
'variant', but from there I'm not quite sure where to go.

Thanks for any assistance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to have a record number change for every record Puget Sound Courier Service Excel Discussion (Misc queries) 1 July 12th 09 03:32 PM
Open new record with selected fields from previous record Design by Sue Excel Discussion (Misc queries) 1 June 12th 09 02:24 PM
Finding last record in month for each of several types of record. Richard Buttrey Excel Programming 5 April 4th 05 02:11 AM
Record Macro - Record custom user actions Sal[_4_] Excel Programming 1 December 23rd 04 03:18 PM
Need help autopopulating next new record with previous record data Harry S[_3_] Excel Programming 2 October 1st 03 10:59 PM


All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"