Solved

Change the search criteria in an access search form

Posted on 2007-11-29
9
459 Views
Last Modified: 2013-11-28
I want to be able to search by date or surname or table name in a form.  How would I do this?
These are the names of the tables:  LEO, BSC, SLP, MYCP.
0
Comment
Question by:Dier02
  • 5
  • 3
9 Comments
 
LVL 84
ID: 20372910
When you say "search", do you want to locate a single record on the form and move to that? Or will there possibly be multiple hits from the search?

Is your form based on all 4 tables (i.e a Query); if not, how are the 4 tables represented on the form?
0
 

Author Comment

by:Dier02
ID: 20372935
Form is based on a query.  I want the query to search for a surname and display the data in a form.  I also want it to state that the name was not found if the name has been removed from the table.
0
 

Author Comment

by:Dier02
ID: 20372942
I also want the query to include the four tables in the search.  The table names are as above.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84
ID: 20372970
Are the four tables included in the Query? If so, then you can use code like this to locate your names:

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone

rst.FindFirst "LEO.YourNameField='" & Me.txtSearch & "' OR BSC.YourNameField='" & Me.txtSearch & "'"
If Not rst.NoMatch Then
  Me.Bookmark = rst.Bookmark
Else
  Msgbox Me.txtSearch & " not found"
End If

You'd need to change the names of the tables/controls etc to match those in your project. Also, this would only locate the FIRST record ...
0
 

Author Comment

by:Dier02
ID: 20373016
What doyou mean by the first record?  Do you mean if there were more than one entry for the same person it would only show one entry and not the other if, for example there was one in BSC and one in LEO?
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 20373025
That is correct. If you would prefer to Filter your form (i.e. show only those records which match your criteria), then use the Form's Filter property:

'/build your filter string
Me.Filter = "LEO.YourNameField='" & Me.txtSearch & "' OR BSC.YourNameField='" & Me.txtSearch & "'"
Me.FilterOn=True

This would show all of them; the user would have to navigate through them, of course.
0
 

Author Comment

by:Dier02
ID: 20390871
Do you mean it would show all of the records in all four tables or do you mean it would show all records for that surname in all tables?
0
 

Author Comment

by:Dier02
ID: 20390873
or that date
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

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.
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…

679 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