Solved

Message Box, No Records Found

Posted on 2011-09-04
2
437 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 500 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

Technology Partners: 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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

749 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