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