Message box when no Results displayed in Access Search Form

I have one table with a list of records. I have one form in which i have a search utilty for those records. The code for the search is

Private Sub Soft_Click()
Dim StrNewRecord As String
    StrNewRecord = "SELECT * FROM [Contents]" _

    Me.RecordSource = StrNewRecord
   
    Me!SoftText.SetFocus
    StrNewRecord = "SELECT * FROM Contents" _
        & " WHERE Entry Like '*" & SoftText.Text & "*'"
       Me.RecordSource = StrNewRecord
 
End Sub


I want to have a message box appear if no results are found when something is entered into the search box. Please Help!

I also want to incorperate it into the enter key behaviour for which the code is:


Public Sub DVText_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
    Dim StrNewRecord As String
    StrNewRecord = "SELECT * FROM [Contents]" _

    Me.RecordSource = StrNewRecord
   
   Me!DVText.SetFocus
    StrNewRecord = "SELECT * FROM Contents" _
        & " WHERE [Disc No/Version] Like '*" & DVText.Text & "*'"
    Me.RecordSource = StrNewRecord
    End If

End Sub


Thanks!
nickfromleedsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TommySzalapskiCommented:
Move to the end on the clone (so you don't mess up the original)
Me.RecordsetClone.MoveLast

Open in new window

Then you can see where you landed
If Me.RecordsetClone.RecordCount = 0 Then
  MsgBox "No results found"
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nickfromleedsAuthor Commented:
Worked outright. Excellent, thankyou.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.