Solved

Search textbox on a form

Posted on 2014-10-27
4
287 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
ID: 40407230
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
ID: 40407261
Attached.  Thanks.
IssuesDesktopDatabase.zip
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40408103
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
ID: 40408401
Scott,

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

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 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