Solved

Search textbox on a form

Posted on 2014-10-27
4
270 Views
Last Modified: 2014-10-28
Microsoft has a template named "IssuesDesktopDatabase.accdb" and on one of the forms is what appears to be a simple search textbox.  This is what it looks like...

Search
But I'm trying to figure out what goes on beneath the surface of the textbox.  It seem that if the user enters a string of characters the function will find records that have that string of characters in any field.  

Does anyone know how this works?  If I convert the macros to VBA code it doesn't seem to work and I'd like to duplicate this on a form.

--Steve
0
Comment
Question by:SteveL13
  • 2
  • 2
4 Comments
 
LVL 84
Comment Utility
It would help greatly if you either (a) let us know where we can review the template or (b) zip up the database and post it here.
0
 

Author Comment

by:SteveL13
Comment Utility
Attached.  Thanks.
IssuesDesktopDatabase.zip
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
Looks like each form is based on a query, and that query includes a Field named "Searchable". That field basically concats all the values from each row into a single Field. For example, the IssuesExtended query has a Field like this:

Searchable: [Issues].[ID] & " " & [Summary] & " " & [Status] & " " & [Priority] & " " & [Category] & " " & [Project] & " " & [Keywords] & " " & [Resolution] & " " & [ResolvedVersion] & " " & [Users].[FullName] & " " & [Users].[Email] & " " & [Users_1].[FullName] & " " & [Users_1].[Email]

The box then has an embedded macro that searches THAT field for the value the user enters. To see that macro, open the form in Design view, select the Search box, and click the build button next to the AfterUPdate event in the Properties sheet. YOu'll see several steps to that macro, but the one you're looking for is the second If - End If step. In that, you'll see a SetTemp action and a SetFilter action that performs the search.

FWIW - to me, this is a poor way to handle things, since the concat process could definitely slow things down if you put too many fields in there, or as the number of rows begin to climb. You can do the same thing by creating a valid WHERE clause and assigning that to the Filter field. To me, this would be a much cleaner, and more performant, method to use to create a search in this manner.
0
 

Author Comment

by:SteveL13
Comment Utility
Scott,

Excellent insight.  I truly appreciate it. Thank you.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

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

11 Experts available now in Live!

Get 1:1 Help Now