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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where's the error. Help Please!

Status
Not open for further replies.

onpnt

Programmer
Dec 11, 2001
7,778
US
I'm reading a DB and trying anyways to meet a criteria and if that is met fill in a list box with part of the row. I know my problem is in my array creation or adding to it but I'm at a loss. Any help much appreciated. Thanks
<%
'create arrays
DIM ProcArray()
DIM ProcPriceArray()
REDIM ProcArray(4)
REDIM ProcPriceArray(4)
Response.Write(&quot;<SELECT&quot;)
Do until Recordset.EOF
for x=0 to Recordset.Fields.count-1 'have to do this to get all of them
if Recordset(&quot;PartCode&quot;) = &quot;P&quot; Then 'get processor
ProcArray(x + 1)=Recordset(&quot;PartDesc&quot;)
ProcPriceArray(x + 1)=Recordset(&quot;Price&quot;)

Response.Write(&quot;<OPTION>&quot;)
Response.Write(ProcArray(x) & &quot; &quot;)
Response.Write(&quot;$&quot; & ProcPriceArray(x))
Response.Write(&quot;</OPTION>&quot;)
next 'so we populate all the records

Recordset.MoveNext

Loop
Response.Write(&quot;</SELECT>&quot;)
%> provide tools to let people become their best.
 
your are missing an end if for the following statement

if Recordset(&quot;PartCode&quot;) = &quot;P&quot; Then 'get processor
 
Sorry, missed it when I copy/pasted the code. It is there though. provide tools to let people become their best.
 
I'm getting the same record stated four times then it goes to the next. like this

flag one $1.50
flag one $1.50
flag one $1.50
flag one $1.50

flag two $1.50
flag two $1.50
flag two $1.50
flag two $1.50

I can't figure out why but I need it like this
flag one $1.50
flag two $1.50 provide tools to let people become their best.
 
You also need an > at the end of the first <select This is not a bug - it's an undocumented feature...
;-)
 
I've resorted to testing by simply writing the arrays instead of using the list box but I get the same thing.
Thanks for getting my lazy mistakes Jonax and SarkMan provide tools to let people become their best.
 
What DO you get?

If you show us your output, we might be able to help... This is not a bug - it's an undocumented feature...
;-)
 
Here's my results
Flag one $1.50
Flag one $1.50
Flag one $1.50
Flag one $1.50
Flag two $2.00
Flag two $2.00
Flag two $2.00
Flag two $2.00
Flag three $2.50
Flag three $2.50
Flag three $2.50
Flag three $2.50
Flag four $2.90
Flag four $2.90
Flag four $2.90
Flag four $2.90

provide tools to let people become their best.
 
i think your problem might be in the for loop.
the for loop is looping thru each field in a row.
so in your row if Recordset(&quot;PartCode&quot;) = &quot;P&quot; then you will be adding elemens to your array for each field in the row.

try the code below(put in your end if wherever it is)

<%
'create arrays
DIM ProcArray()
DIM ProcPriceArray()
REDIM ProcArray(4)
REDIM ProcPriceArray(4)
Response.Write(&quot;<SELECT&quot;)
Do until Recordset.EOF

if Recordset(&quot;PartCode&quot;) = &quot;P&quot; Then 'get processor
ProcArray(x + 1)=Recordset(&quot;PartDesc&quot;)
ProcPriceArray(x + 1)=Recordset(&quot;Price&quot;)

Response.Write(&quot;<OPTION>&quot;)
Response.Write(ProcArray(x) & &quot; &quot;)
Response.Write(&quot;$&quot; & ProcPriceArray(x))
Response.Write(&quot;</OPTION>&quot;)


Recordset.MoveNext

Loop
Response.Write(&quot;</SELECT>&quot;)
%>
 
I guess you could just lose the for-to-next loop, or ? This is not a bug - it's an undocumented feature...
;-)
 
SarkMan you are awesome. It works now. I thank you endlessly. Hope I can return the favor soon. provide tools to let people become their best.
 
Sorry SarkMan...
I guess I was stating the obvious.. This is not a bug - it's an undocumented feature...
;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top