Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imroper Dynamic Array

Status
Not open for further replies.

minoad

Programmer
Mar 28, 2001
138
US
I have made a mistake in the use of a dynamic array, but cannot seem to find the bug. I am using a dynamic array to create a dropdown. Very simple code inside of the function that creates the array, but it appears to be adding to the endo of each bound everything i have created to that point.
Example:
(0)A
(1)AB
(2)ABC
(3)ABCD
Where it should be
(0)A
(1)B
(2)C
(3)D

The code is below, any ideas would be appreciated.

set con=server.CreateObject("adodb.connection") 'connection object
con.Open application("constr")



dim strInfo
strInfo = ""

dim arrGroup()
i = 0
sql = ""
sql = sql & "Select *"
sql = sql & " from table"

Dim Rs
Set Rs = server.createobject ("adodb.recordset")
Rs.Open Sql, con, 2, 2

Do until Rs.Eof
if rs.fields(&quot;show&quot;).value <> &quot;N&quot; then

if rs.fields(&quot;grp&quot;).value = strGroup then
strInfo = strInfo & &quot;<option SELECTED&quot;
else
strInfo = strInfo & &quot;<option &quot;
end if

strInfo = strInfo & &quot; value='&quot;& rs.fields(&quot;grp&quot;).value &&quot;'>&quot; & rs.fields(&quot;descr&quot;).value &&quot;</option>&quot;
ReDim preserve arrGroup(i)
arrGroup(i) = strInfo
i = i + 1
End if
Rs.Movenext
Loop


Micah A. Norman
 
With each loop step moving through the record you need to intitialize strInfo. ie,

Do until Rs.Eof
strInfo = &quot;&quot;
...
RS.movenext
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top