Solved

Search textbox on a form

Posted on 2014-10-27
4
291 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
[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
  • 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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…
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…

726 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