Solved

Help with FindNext in conjunction with FindRecord

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

770 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