Solved

Change the search criteria in an access search form

Posted on 2007-11-29
9
461 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
[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
  • 5
  • 3
9 Comments
 
LVL 85
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 85
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 85

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

688 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