Navigate through a recordset using Previous and Next buttons
I am working with two asp pages, Page1.asp and Page2.asp
On page1.asp I have a listbox... when I select an item it will POST the value to Page2.asp...
The value is then passed into a query:
sql = "SELECT * FROM Table1 WHERE Number = " & Record
oRS.Open sql, oConn,1,3
With this data it populates the text boxes... this work perfectly...
I want to be able to Navigate through the recordset I queried by using a Next and a Previous button while populating the text boxes with the new values...
Thank you amitabh.. This example is good if you want to SELECT * ... then when you click the Next button the next record is displayed..
My problem is on Page1.asp, when I select an item from the list.. it takes this value and POSTS it to the server...
When Page2.asp loads up it takes this value and sticks it into the sql query...
I understand that I must select a range rather than one record... obviously if you click on Next there is no record because in the query it selected only one record...
My question is , is there a way to select * and display the recordset at a ceratin record rather than the begiining of the recordset...
Example:
Page1.asp I click on John, the is brings the value "John" and a record number associated to this record to Page2.asp...
I execute the query with something like this, SELECT * FROM TABLE1 WHERE Name = "John" and Date=#01/01/01#
This will give me all the records for John on that date, this is a step further then selecting only one record...
Now the thing is I want to populate the text boxes starting at the record number that I brought over for John and that date...
Normally if I have
Record1 John 01/01/01
Record2 John 01/01/01
Record3 John 01/01/01
The text boxes will be populated with Record1, I want to the text boxes to be populated with the Record number that was brought over from Page1.asp.... record2
I am not getting the correct meaning of your qustion, but you can try "AbsolutePosition" property of the recordset. I will take a second look at the question to see if I get a clearer view.
Lets say I select * FROM TABLE1 WHERE LastName = "John" and Date = #01/01/01#
This will take evrything with the LastName John on that date...
Lets say there are 10 records that result in this query..
The results are:
Record1 Smith
Record2 Smith
Record3 Smith...
I want the text boxes to be populated with a specific record of my choice, for example Record2.... the records related to record2 will be populated in the text boxes and when I click Next it will populate the text box with record3
I want the text boxes to be populated with a specific record of my choice, for example Record2.... the records related to record2 will be populated in the text boxes
I think you would not have problem reaching till this stage.
and when I click Next it will populate the text box with record3
Use AbsolutePosition property of the recordset to point the cursor of your recordset to this position.
This is assuming that you want to work within the same recordset.
1) Sort the results.
2) If you want a specific record based on something other than the name, use that in the where clause as well.
oOOo--oOOo
__/\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP [email protected] [email protected] Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..