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!

subscript out of range 1

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
Hello all, the below code is giving me an error of

Microsoft VBScript runtime error '800a0009'

Subscript out of range: '17'

Not sure where it is at - below is my code with the error line marked. Thank you in advance for any assistance.


<%
Dim fieldNames()
ReDim fieldNames( rstemp.fields.count-1 )

Response.Write &quot;<TR>&quot; & vbCrLf
For i = 0 To rstemp.fields.count - 1
curname = rstemp.fields(i).name
fieldNames(i) = curname
Response.Write &quot;<TH>&quot; & curname & &quot;</TH>&quot; & vbCrLf
Next
Response.Write &quot;</TR>&quot; & vbCrLf


' Now lets grab all the records
alldata=rstemp.getrows
Call CloseAll

numcols=ubound(alldata,1)
numrows=ubound(alldata,2)
FOR rowcounter= 0 TO numrows
response.write &quot;<tr>&quot; & vbcrlf
FOR colcounter=0 to numcols
thisfield=alldata(colcounter,rowcounter)
if isnull(thisfield) then
thisfield=shownull
end if
if trim(thisfield)=&quot;&quot; then
thisfield=showblank
End If
%>
<TD Valign=&quot;top&quot;>
<INPUT Name=&quot;<%=fieldNames(i)%>&quot; Value=&quot;<%=thisfield%>&quot; Class=&quot;inputbox&quot;>
</TD>
<%
Next


response.write &quot;</tr>&quot; & vbcrlf
NEXT
response.write &quot;</table>&quot;
%>
&quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
Hi John, thank you for you response.

I get the same error. Any ideas?

Thank you &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
In the line that generates the error, why do you have &quot;fieldNames(i)&quot;? &quot;i&quot; isn't used in the two nested For loops wrapping that statement; it retains its value from the previous For loop. At this point, &quot;i&quot; should contain the value of rstemp.fields.count, which is certainly out of bounds.

I think you mean &quot;fieldNames(colcounter)&quot;. Hope this helps.
 
the FieldNames(i) is the dimmed value that incriments up top into an array. It also up top displays as header rows.

Which I thought should work - but lol lemme give your idea a shot too.

Thank you &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
wow

it worked!

I've just got to sort out some kinda spacing problem, but view source shows it perfectly!

You da tek-tipper! &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top