Dynamic Array

spinkung

Registered User.
Local time
Today, 17:14
Joined
Dec 4, 2006
Messages
267
Hi All,

I am trying to create a variable array and fill it based on the selection from a table.

This doesn't seem to work...
Code:
Do
rs.MoveFirst
[COLOR="Red"]service_array(iCount)[/COLOR] = rs!service_id
iCount = iCount + 1
rs.MoveNext
Loop Until rs.EOF
.. it fails on the red section. can i use a variable to set an array value??

if not how do i dynamically set the size of an array based on the row count of a sql select query??

Thanks,
spin.
 
you can do it like this:

Code:
dim blah() as string 'change to appropriate data type

set rs = something

redim blah(0 to rs.recordcount - 1)
icount = 0
rs.MoveFirst

Do
service_array(iCount) = rs!service_id
iCount = iCount + 1
rs.MoveNext
Loop Until rs.EOF

Not sure I see the point though. A recordset is an array with a few extra bells and whistles so I'm not sure why you want to create a new array.
 
Last edited:
that worked a treat. thanks.

i should do some more learning on rs's by the looks of it.

thanks.
 

Users who are viewing this thread

Back
Top Bottom