Results 1 to 3 of 3

Thread: Can you help me with this run-time error?

  1. #1

    Thread Starter
    Lively Member brjames's Avatar
    Join Date
    Jan 2000
    Location
    Tenby, Wales, UK
    Posts
    121
    Having nearly finished a harbour booking system, I am currently tidying up the project and adding some error checking etc.

    The problem is that I have a form with a data store and have previous and next buttons along with some text boxes to go through data from a database. When I use the previous and next buttons to go through the data they work fine until I go further than the last or first record. Then I get a run time eror that says that there is no current record.

    How can I code some error checking that tells the person that there is no more records if they press the buttons to go further than the last record instead of having a run-time error?

    Thanks in advance!

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Peterborough, Cambs, England
    Posts
    176
    If rs.Bof = False And rs.Eof = False then
    'Your code goes here.
    Else
    MsgBox "No more records.", VbInformation, App.Title
    End If



    Hope this is ok.

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Paul's right. Just a little tweak if you want individual messages:
    Code:
    If rs.BOF = True
       Msgbox "You Are Viewing The First Record.", vbInformation, "Invalid Selection"
       Exit Sub
    End If
    
    If rs.EOF = True then 
       Msgbox "You Are Viewing The Last Record.",    vbInformation, "Invalid Selection"
       Exit Sub
    End If
    
    'Your Code Here for Valid Records

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