Results 1 to 9 of 9

Thread: Code for 30 recs at a time?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    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?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    ON, CAN
    Posts
    265
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    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?

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    truthfully very lazy
    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....

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    ON, CAN
    Posts
    265
    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

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    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).

  7. #7
    Lively Member
    Join Date
    Jun 1999
    Location
    Garden Grove, CA, USA
    Posts
    110

    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.
    ngphuocthinh

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    What is this "Paging" of which you speek? Could someone enlighten me so I may become whole again?

  9. #9
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    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:
    1. Dim current_page  as integer
    2. Private Sub Form_Load()
    3. Const NumPages = 10 'number of records per page
    4.  
    5. rs.PageSize = NumPages
    6. Text1.Text = rs.Fields("ID")
    7. Current_Page = 1 'current page variable to 1
    8.  
    9. end sub
    10.  
    11. Private Sub Command1_Click()
    12. Current_Page = 2 'specifies which page to move to
    13. rs.AbsolutePage = Current_Page 'moves to the next page
    14. Text1.Text = rs.Fields("ID") 'sets text1's value
    15. 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
  •  



Click Here to Expand Forum to Full Width