Solved

Help with FindNext in conjunction with FindRecord

Posted on 2013-06-21
3
292 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

8 Experts available now in Live!

Get 1:1 Help Now