Solved

Help with FindNext in conjunction with FindRecord

Posted on 2013-06-21
3
293 Views
Last Modified: 2013-09-21
I am using MS Access 2010 and trying to re-create the function of the search function on the navigation bar using a text field on the form as I will be removing the bar as part of the design. I have created the unbound search field and have it working fine with the following code.

Private Sub SearchBox_AfterUpdate()
Dim SearchCriteria As String
SearchCriteria = Me.SearchBox

Me.SearchBox = Null

DoCmd.FindRecord SearchCriteria, acAnywhere, False, acSearchAll, True, acAll


End Sub

Open in new window


This works exactly as the search on the bar, other than the FindNext where each time you press enter, the search bar finds the next match. I am struggling as to how to implement the find next with my unbound search field.

Would be grateful for any help?
0
Comment
Question by:martmac
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39265380
The last argument in FindRecord indicates whether to start at the first record, or at the current record. So to begin your search on the current record:

DoCmd.FindRecord SearchCriteria, acAnywhere, False, acSearchAll, True, acAll, False

Since you're doing this in the AfterUpdate event, however, it would seem that the user is entering a new Search term each time - so how would you know when the user wants to start a NEW search, or continue with their existing search?
0
 

Author Comment

by:martmac
ID: 39265467
Understood,

Re the AfterUpdate what I am looking to replicate is exactly what the toolbar search does, just unclear how to code it. If search is for smith then I want it to find the first smith and highlight it as it does, bu then be able to press a Find Next button for it to find the next record based on the string that is already held.

Hope this makes sense?
0
 

Author Closing Comment

by:martmac
ID: 39511972
Apologies for the late response on this one, I have been unwell, so not at work. All sorted now thanks for your help.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in Rs.MoveNext & Duplication of Record 14 25
append to an ms access field 6 21
Update Access FrontEnd by Version # 9 19
Access coding 2 7
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

911 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

28 Experts available now in Live!

Get 1:1 Help Now