Solved

Change the search criteria in an access search form

Posted on 2007-11-29
9
454 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now