Solved

Find a record with an Input box using LIke

Posted on 2010-08-28
7
415 Views
Last Modified: 2013-11-28
Experts, I need to first modify the below to handle "Like".  I also would like to know how to properly handle >1 record using the "Like".  It would be best to be able to hit "Next" or something like that to see the next record when using Like.  I am assuming this type of issue has been dealt with and someone can give me some code fot it.

thank you

Me.Recordset.FindFirst "[End User] =" & Chr(34) &  InputBox("Enter Name") & Chr(34)
0
Comment
Question by:pdvsa
7 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
To get the Like working:Me.Recordset.FindFirst "[End User] Like '*" & InputBox("Enter Name") & "*'"That is a "contains" match.  For "begins with":Me.Recordset.FindFirst "[End User] Like '" & InputBox("Enter Name") & "*'"For "ends with":Me.Recordset.FindFirst "[End User] Like '*" & InputBox("Enter Name") & "'"
0
 

Author Comment

by:pdvsa
Comment Utility
Ok.   How does it handle >1 match?
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
What are you trying to do?  FindNext is all about finding *a* record, not multiple records...
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:pdvsa
Comment Utility
Matthews, i am trying to find all records with a msgbox.   I think that "like" would be a start but not sure if i am on the right track.  

Is this Find Next:
  Me.Recordset.FindFirst "[End User] Like '*" & InputBox("Enter Name") & "*'"

it only finds the first record right?
0
 
LVL 6

Expert Comment

by:JVWC
Comment Utility
A button added to a form using the wizard will create this functionality for you.
Add a button in design mode and choose "Record Navigation" and "Find Record" in the wizard.

Cheers
JC
0
 
LVL 1

Assisted Solution

by:mgoodspeed
mgoodspeed earned 50 total points
Comment Utility
mathewspatrick has the good code.
You could set the RecordScource Property of a subform to the SQL string generated in his code to display the records, then select the one you want to modify.

Alternately, you could use a popup form if there are > 1 rows, then double-click it to navigate to the record you want
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 450 total points
Comment Utility
If you want all records matching certain criteria, then instead of using FindFirst, why not simply open a recordset that will have only the records you care about?  You can then loop through that recordset to build up your MsgBox prompt.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now