Solved

Help with FindNext in conjunction with FindRecord

Posted on 2013-06-21
3
296 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 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