Solved

Help with FindNext in conjunction with FindRecord

Posted on 2013-06-21
3
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

734 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