?
Solved

Message Box, No Records Found

Posted on 2011-09-04
2
Medium Priority
?
439 Views
Last Modified: 2012-08-13
I have the following coding in a Access 2007 form with Sub Forms.  I have a find button that on click the
coding finds the record in the database.  However, I need a messag box to appear when find is selected and no records are found.  Where do I put this and what coding do I use?  

Private Sub Command9_Click()

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PK_DriverLicenseID] = '" & Me.Text10 & "'"
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark


End If
End Sub
0
Comment
Question by:jjc9809
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 36481559

Private Sub Command9_Click()

Dim rs As DAO.Recordset

Set rs = Me.Recordset.Clone
rs.FindFirst "[PK_DriverLicenseID] = '" & Me.Text10 & "'"
If rs.NoMatch = True Then
    ' Not Found
    ExitSub
Else
    Me.Bookmark = rs.Bookmark
End If
End Sub

mx
0
 
LVL 75
ID: 36481681
And we can simplify this also (and there was a typo above ... ExitSub - no space)

    With Me.Recordset.Clone
        .FindFirst "[PK_DriverLicenseID] = '" & Me.Text10 & "'"
        If .NoMatch = True Then
            ' Not Found - Do whatever
            Exit Sub
        Else
            Me.Bookmark = .Bookmark
        End If
    End With

mx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question