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

Previous and next buttons quandry. 1

Status
Not open for further replies.

charanch

Programmer
Jan 3, 2004
55
US
Hello,

I have the following code I use for previous and next buttons with a table that has an autonumber field as the primary key, so aff is numeric. Simple and works fine.

aff=Request.QueryString("aff")

nextaff=aff+1
prevaff=aff-1
response.Write &quot;<td valign=top><input type=submit name=next value='NEXT' onclick=self.location.href=('?aff=&quot; & nextaff & &quot;')><br>&quot;
response.Write &quot;<input type=submit name=next value='PREV' onclick=self.location.href=('?aff=&quot; & prevaff & &quot;')>&quot;

Problem: I have another use for this code but the table doesn't have an autonumber field as the primary key and I don't know how to modify the above code so I can use the previous and next buttons. I don't need anything complicated like paging, just previous and next. Only one record at a time. I hope somebody can help with this. Thanks in advance.
 
I'd seriously consider regular paging:

Database Paging

You see autonumbers can have holes where deleted records no longer exist so the plus one thing might not always work. And of course if you're already at the highest number how can there be a Next...

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
Thanks very much. It just seems like such overkill when all I need is next and previous, one record at a time. I don't need to group records into groups of five or 10. there aren't enough records. I'm showing all records in a table with an edit button. When the user clicks edit the selected record pops up. I thought it might be a nice touch to have a next/previous button available so they could just move to the next or previous record instead of going back to the table. I'll give it a try though. Maybe I can just pull out the code I need... Many thanks again for your thoughts!
 
<<
I don't need to group records into groups of five or 10.
>>

Well at least if you have the paging technology under your belt and it works for you with one record at a time, you'll have it for a future project where you DO want to only show say 100 records per page instead of the whole recordset which might contain say 5,000 records.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
I totally agree. I'll use it. Thanks again for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top