Adding Index Number to a Dynamic Array

  • Thread starter Brian Piotrowski
  • Start date
B

Brian Piotrowski

Hi All,

I've probably done this before, but for the life of me I can't remember how
I did it. I need to move values from a DB table into an array to be used
for other queries. The number of records will vary, so I need to make the
array dynamic. Can someone remind me how I can increment the index when I
write a new record? Here's a sample of the code I wrote:

If rsGETKD.EOF = False Then
Dim KDLOTSQ
KDLOTSQ = rsGETKD.GetRows()
iRecFirst = LBound(KDLOTSQ, 2)
iRecLast = UBound(KDLOTSQ, 2)
iFieldFirst = LBound(KDLOTSQ, 1)
iFieldLast = UBound(KDLOTSQ, 1)
Dim KDLTable
MyCount = 0
For I = iRecFirst To iRecLast
MyText=""
For J = iFieldFirst To iFieldLast
MyText=MyText & KDLOTSQ(J, I)
Next
KDLTable(MyCount) = MyText
MyCount = MyCount + 1
Next
End If

What this code is supposed to do is read a DB table that contains two
values. These two values are written to another array (KDLTable) that I can
use as a reference later on in my ASP (I need to read this table four times
at four different record locations).

When I run this code, I get an "800a000d Type Mismatch" Error. Looking at
the code, the program breaks at "KDLTable(MyCount) = MyText". I'm sure the
program is failing when the system tries to use MyCount as the index number.

How can I increment the index number for each value in the table? For
example, if there are three records in the table, (ABC123, DEF456 and
GHI789), I would like to write in this manner:

KDLTable(0) = ABC123
KDLTable(1) = DEF456
KDLTable(2) = GHI789

Any ideas would be appreciated.

Thanks!

Brian.
 
B

Brian Piotrowski

In this case, what is (N) equal to? How do I increase the value of the
index number when I read a new record? Is the REDIM statement within the
next loop for the recordset?
 

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

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top