MS Access Tutorial: Displaying an alert message when recordset returns no value


To make the user interface more friendly in nature it’s a good approach displaying an Alert Message when MS Access Query returns no value to its corresponding recordset.

How To:

By using the MS Access RecordsetClone and RecordCount Property we can return a message with an empty recordset.

If Me.RecordsetClone.RecordCount <= 0 Then
MsgBox ("No records available." & vbCrLf & "Either there is no record found OR wrong search data provided.")
End If

The RecordsetClone property is cloning the state of the recordset in the form while RecordCount is counting if there is any record in the recordset. If no records exist then we are showing the message in MsgBox.

Note: The  & vbCrLf & is adding a new line in the message box message.

For more about MS Access RecordsetClone property go here.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.