|
-
Aug 28th, 2002, 07:58 PM
#1
Thread Starter
Hyperactive Member
Code for 30 recs at a time?
Hi, I'm using DAO and Access. I want to display 30 consecutive rows at a time out of about 500 on a form using formName.print and an option button to open the form corresponding to each row holding a contextid as a value. I want to use another button to get next 30 rows and display a button to go back 30 if it can. I have wrote similiar code in the past but am stretched for time and truthfully very lazy. Could anyone share some code to help me out?
-
Aug 28th, 2002, 08:38 PM
#2
Hyperactive Member
hey, hopefully i understand correctly....
why not try a simple loop to itterate the recordset forward or backwards...
Code:
command button forward
for intCounter = 0 to 29
if not recordsetObject.EOF then
RecordsetObject.movenext
form.print recordset.field(0)
Else
Exit For
End if
Next
Code:
command buttonbackwards
for intCounter = 0 to 29
if not recordsetObject.BOF then
RecordsetObject.moveprevious
form.print recordset.field(0)
Else
Exit For
End if
Next
something like that (btw.. not tested)
Regan
For excellent Winsock example check here WINSOCK
-
Aug 28th, 2002, 08:59 PM
#3
Thread Starter
Hyperactive Member
No... That much I've got but thanks anyway. How do I hold the cursor from one set of 30 to the next and back again? Also how do I get the form.print to start at the top again?
-
Aug 28th, 2002, 09:21 PM
#4
PowerPoster
Well
Nice way to get help...
Keep track of your starting number 1, 31, 61, ...
Then add all your records into an array with a record indicator....
When changing to show elements of 30, loop all elements in array and find starting number in array. When founf, loop to extract the 30 rows from the array...
Confusing, but it works...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Aug 28th, 2002, 11:56 PM
#5
Hyperactive Member
you might want to use bookmarks also...
also, if you clear the form, the print should start back at the top
Regan
For excellent Winsock example check here WINSOCK
-
Aug 29th, 2002, 11:31 AM
#6
Thread Starter
Hyperactive Member
James Stanich: I know I could hold an array of the whole damn thing when I open the rs but Access is already holdin it and I guess it's the principle of the matter. I want access to the array Access is holding.
Thanks for help! Because I'm "very lazy" and can appreciate other's laziness. I'll try to motivate myself to share the code so others like my self can just grab it when I'm done. Untill then here's my problem. I don't want to put in any unique id's for the rows and I can't autonumber cause I use deletes and only repair nightly so any loops that search on input would be brocken.
MY BIG QUESTION:
So for now if I'm on record #30 then I close my connection. How do I refer to record 30 when I reopen the database so I can continue? I'm using Access and please keep in mind I'll probably migrate eventually to Oracle (or another real database).
-
Aug 29th, 2002, 02:25 PM
#7
Lively Member
Have you try paging?
I've did some ASP programing and have done paging. it enables you to go back and forth like turning pages. i think there's a way in VB that enables you to do the samething too.
-
Aug 29th, 2002, 07:55 PM
#8
Thread Starter
Hyperactive Member
What is this "Paging" of which you speek? Could someone enlighten me so I may become whole again?
-
Aug 29th, 2002, 08:57 PM
#9
PowerPoster
thinh is correct vb does like aps have a page function.
Works exactly the same!
Basically paging allows you to set how many records per page you want to display.
example:
VB Code:
Dim current_page as integer
Private Sub Form_Load()
Const NumPages = 10 'number of records per page
rs.PageSize = NumPages
Text1.Text = rs.Fields("ID")
Current_Page = 1 'current page variable to 1
end sub
Private Sub Command1_Click()
Current_Page = 2 'specifies which page to move to
rs.AbsolutePage = Current_Page 'moves to the next page
Text1.Text = rs.Fields("ID") 'sets text1's value
End Sub
later
b
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|