Solved

Change the search criteria in an access search form

Posted on 2007-11-29
9
458 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

829 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