Record set to array?

  • Thread starter Thread starter mazzarin
  • Start date Start date
M

mazzarin

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top