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

records listed on page

Status
Not open for further replies.
May 9, 2000
446
GB
Hi I've got a search screen that lets my users set how many results they want displayed, using a drop down they can say All, 10, 25, 50 etc etc.

Anyway the number is passed as cnt2 hre's my code:

<%
Dim limi, cnt
If Request("cnt2")<>"" Then
limi = Request("cnt2")
Else
limi = 11 'default of 10 records
End If

cnt=1
while not (lg.eof) AND cnt < limi
%>
my table row with search results in goes here
<%
cnt=cnt+1
lg.movenext()
wend
%>

but for some reason its not working. When cnt2 is null the page only shows 10 results but if cnt2 contains a value the page just shows everything... can someone show me where I'm going wrong?
 
The direct error your getting is probably a string/number issue, try doing a cInt on the linetat asigns the limi value from the Request collection:
Code:
limi = cInt(Request("cnt2"))

The next thing you might want to look into is using te built-in paging for a Recordset. With recordset paging you can specify the number of records per page and then tell it which page you want to display (or ask how many there are, etc). This is quicker then anually scrolling through the recordset to find the record you want to start on then displaying x records. There are FAQs that can provide more info, such as: faq333-3229
And searching here or on google for "asp recordset paging" ought to net you a few thousand results. I urge you tro try this method, it will make your code more efficient and more maintainable in the long run.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top