Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Message Box
Dwight Arroyo 
    
4 years ago
Need code to tell user if the criteria entered is NOT found, a message box will alert the user that "The record was not found" or something similar.
Kevin Robertson  @Reply  
          
4 years ago
Dwight Arroyo OP  @Reply  
    
4 years ago
This code is incomplete
Richard Rost  @Reply  
          
4 years ago
He wasn't giving you code. He gave you links to videos you can watch to answer your question.
Dwight Arroyo OP  @Reply  
    
4 years ago
Hello Richard:
Glad you are back!
Thank you for clearing this up.
Dwight Arroyo OP  @Reply  
    
4 years ago
The following "find" rrecord code was taken from one of your lessons. I would like to alert the user via MsgBox in this CODE block that if the criteria specified to look for is NOT found, then I can tell the user that the data was not found.

Private Sub FirstNamebtn_Click()

Dim X As String
X = InputBox("Enter all or part of a First Name to find:", "First Name")

If X = "" Then
Exit Sub

DoCmd.GoToControl "FirstName"
DoCmd.FindRecord X, acAnywhere, False, acSearchAll, False, acCurrent, True

End Sub
Richard Rost  @Reply  
          
4 years ago
There are a couple of ways you could do it. In this case, you could just use the InStr function to make sure that the record you finally landed on actually contains that text.

If InStr(FirstName,X)=0 then MsgBox "Nothing to see here. Move along."

Or something like that.

String Functions
Dwight Arroyo OP  @Reply  
    
4 years ago
Thanks Richard:

I hope you and family are all doing well.
I would have never figured this one out.

I have the CODE for Visual Studio to do this using SQL statements, but not a clue here in Access.

The lessons are so excellent, I decided to port my application to Access using your help. Access is more
integrated I feel.

So, thanks again!
Richard Rost  @Reply  
          
4 years ago
Yeah, there's a lot less you have to program yourself with Access. Most of the "database stuff" is already there for you.
Dwight Arroyo OP  @Reply  
    
4 years ago
I commented out the original "If" statement, put your solution after the DoCmds to find the record and it works like a charm.

Once again Richard, thank you for your help. I will now tackle the multiple field search tutorials!

Private Sub FirstNamebtn_Click()

Dim X As String
X = InputBox("Enter all or part of the First Name to find:", "First Name")

'If X = "" Then
'Exit Sub

DoCmd.GoToControl "FirstName"
DoCmd.FindRecord X, acAnywhere, False, acSearchAll, False, acCurrent, True

If InStr(FirstName, X) = 0 Then
MsgBox "Criteria not found!"
Exit Sub

    End If

'End If

End Sub
Dwight Arroyo OP  @Reply  
    
4 years ago
Here is the final version of the search tutorial along with the "criteria not found" alert.

The original "If" statement now works by adding an "Else" after it.

Private Sub FirstNamebtn_Click()

Dim X As String
X = InputBox("Enter all or part of the First Name to find:", "First Name")

If X = "" Then
Exit Sub

    Else

DoCmd.GoToControl "FirstName"
DoCmd.FindRecord X, acAnywhere, False, acSearchAll, False, acCurrent, True

If InStr(FirstName, X) = 0 Then
MsgBox "Criteria not found!"
Exit Sub

    End If

End If

End Sub
Dwight Arroyo OP  @Reply  
    
4 years ago
Dwight - South Carolina

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 10:06:03 AM. PLT: 1s