Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Barnsley, Yorkshire, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "End of Recordset" MessageBox

    Hi

    I have searched through the forum and found a couple of threads that come close on this matter, but i am still unable to solve my problem:

    I have built a small Access97 app. for offering exam prep. questions. I have a form that selects 20 questions at random from a table, and the user selects the answer from a multiple choice type answer set. That part is all working fine.

    I have added my own record navigation buttons (using the wizard) and "Question x of y" text box as some users may not find the original ones easy to see. What i am trying to do is modify the code to take care of the "you can't go to a specified record" error messages. For two reasons: (1) because it looks unprofessional, and (2) because if i can pick up that point i can display my own message box relating to maybe what the user should do next.

    Any help would be much appreciated.

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Recordset Message

    Could your code test for YourRecordset.EOF? (the end of file marker)

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Barnsley, Yorkshire, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Recordset Message

    Hi

    I've been trying to do that, but without much success. Here's my code:

    Dim dbs As DATABASE, rst As Recordset

    Set dbs = Currentdb
    Set rst = Me.RecordsetClone

    With rst
    If rst.EOF Then

    Exit Sub

    Else

    MsgBox ("OK Message")

    docmd.GoToRecord , , acNext

    End If

    End With

    If i run this under the "Next record" button, i still get my test message and "End of recordset" message. Any ideas where i am going wrong??

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: End of Recordset Message

    Hi Peter,
    Try something like:
    <pre>Dim dbs As DAO.Database, rst As DAO.Recordset, varBookmark As Variant

    Set dbs = CurrentDb
    Set rst = Me.RecordsetClone
    varBookmark = Me.Bookmark

    With rst
    .Bookmark = varBookmark
    .MoveNext
    If .EOF Then
    MsgBox "There are no more records"
    Exit Sub
    Else
    'MsgBox ("OK Message")
    DoCmd.GoToRecord , , acNext
    End If
    End With
    </pre>

    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Barnsley, Yorkshire, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: End of Recordset Message

    Hey, that's perfect!!!!

    Thank you very much for your assistance.

    I guess i need to go away and learn all there is to know about bookmarks.....

    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •