# Need help with an array!

• s15199d
• Expert
• Joined: Feb 20, 2004
• Posts: 524
• Loc: NC, USA
• Status: Offline

February 19th, 2010, 7:56 am

I get a type mismatch on the column0 line every time.
Code: [ Select ]
arrIndex = 0
while not rs.EOF

arr(0, arrIndex) = rs("column0").value
arr(1, arrIndex) = rs("column1").value
arr(2, arrIndex) = rs("column2").value
arr(3, arrIndex) = rs("column3").value
arr(4, arrIndex) = rs("column4").value

arrIndex = arrIndex+1
rs.movenext
wend
1. arrIndex = 0
2. while not rs.EOF
3.
4.     arr(0, arrIndex) = rs("column0").value
5.     arr(1, arrIndex) = rs("column1").value
6.     arr(2, arrIndex) = rs("column2").value
7.     arr(3, arrIndex) = rs("column3").value
8.     arr(4, arrIndex) = rs("column4").value
9.
10.     arrIndex = arrIndex+1
11.     rs.movenext
12. wend

Any suggestions?

Give a man a fish he eats for a day. Teach a man to fish he eats for a lifetime.
• Anonymous
• Bot
• Joined: 25 Feb 2008
• Posts: ?
• Loc: Ozzuland
• Status: Online

February 19th, 2010, 7:56 am

• s15199d
• Expert
• Joined: Feb 20, 2004
• Posts: 524
• Loc: NC, USA
• Status: Offline

February 19th, 2010, 2:30 pm

What a pain in the array...after way too long I've finally solved it...

the issue was with dimensioning the array. here's the fix:

Code: [ Select ]
optionStr = ""
redim preserve arr(3,ubound(arr,2)+1)
while not rs.EOF
arr(0, ubound(arr,2)) = rs("column0").value
arr(1, ubound(arr,2)) = rs("column1").value
arr(2, ubound(arr,2)) = rs("column2").value
arr(3, ubound(arr,2)) = rs("column3").value
rsOptions.movenext
wend
set rs = nothing
1. optionStr = ""
2. redim preserve arr(3,ubound(arr,2)+1)
3. while not rs.EOF
4.     arr(0, ubound(arr,2)) = rs("column0").value
5.     arr(1, ubound(arr,2)) = rs("column1").value
6.     arr(2, ubound(arr,2)) = rs("column2").value
7.     arr(3, ubound(arr,2)) = rs("column3").value
8.     rsOptions.movenext
9. wend
10. set rs = nothing

Give a man a fish he eats for a day. Teach a man to fish he eats for a lifetime.

## Post Information

• Total Posts in this topic: 2 posts
• Users browsing this forum: No registered users and 165 guests
• You cannot post new topics in this forum
• You cannot reply to topics in this forum
• You cannot edit your posts in this forum
• You cannot delete your posts in this forum
• You cannot post attachments in this forum

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.