• “End of Recordset” MessageBox

    Author
    Topic
    #356578

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #528012

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

      • #528016

        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??

        • #528030

          Hi Peter,
          Try something like:

          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
          

          Hope that helps.

          • #528033

            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

    Viewing 0 reply threads
    Reply To: “End of Recordset” MessageBox

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: