General discussion

Locked

Access 2000

By sivickers ·
I am trying to set up a search macro that will search a database form then show the required results. e.g. if I want to search for a name, it would search the database and then show all forms with that name. The question is How do I do it? I am stuck could somebody please help me.....

This conversation is currently closed to new comments.

13 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access 2000

by SteveD In reply to Access 2000

You don't even have to build a macro for this. Access already has very flexible filtering technology built in. You can use the Records/Filter menu or the right-click context menu on an individual field or group of fields. Applying a filter will limit the records shown on your form to those that match whatever filter criteria you supply.

Here's an excerpt from the Help file about applying filters using the right-click menu. See Help for more details.
------------------
Filter records by entering criteria in place in a form or datasheet

Open a table, query, or form in Datasheet view, or a form in Form view.

To filter records in a subdatasheet, first click the expand indicator to display that subdatasheet.

Do one of the following:

To specify the exact field value you want the filtered records to contain, right-click in the field in the datasheet, subdatasheet, form, or subform you're filtering, and then in the Filter For box on the shortcut menu, type the value. For example, to find all the records that have London in the City field, right-click in the City field, and then type London in the Filter For box.

To specify more complex criteria, type the complete expression using the appropriate combination of identifiers, operators, wildcard characters, and values to produce the result you want. For example, to find all the records where the Contact Title field includes the word "Marketing" anywhere in the title, right-click in the Contact Title field, and then type *Marketing* in the Filter For box. To display only the records for orders that were shipped more than 15 days after the specified required date, type [ShippedDate]-[RequiredDate]>15.

To apply the filter and close the shortcut menu, pressENTER.

-----------------------
I hope this helps.

Steve Diamond

Collapse -

Access 2000

by sivickers In reply to Access 2000

thank's but the thing i am looking for is to do the macro so i can then have a main form page with buttons on it like search for names, search for phone numbers then it will display the forms for that search. Sorry

Collapse -

Access 2000

by Lo In reply to Access 2000

Clarification Question - Do you have a database that has the forms in the application and the names on the forms?

If yes, answer above would / should work.

If you are trying to find all the forms in the application that reference a databasefield (or control or module/routine call) that is not in a database per se. The data you are searching is the MetaData of the application.

Not sure about Access 2000 but I don't remember previous versions of Access having that, but I don't do a lot of Access. Get into a module editor and try Edit, Find (or whatever) to see if you can find the names (I did something similar from VB looking for DB Column Names that I had a name change). Lo

Collapse -

Access 2000

by sivickers In reply to Access 2000

what i am trying to do is have a main form page with lots of buttons on it with like say search for a name? search for a phone number. so when i click on it, it shows all records with that name or phone number depending what i wanted

Collapse -

Access 2000

by SteveD In reply to Access 2000

You can add one or more command buttons to your form for this purpose. When the Command Button Wizard pops up, select Record Navigation from the Categories column and Find Record from the Action column. The default behavior of this button will be topop up a search window allowing a search on the last form field that had focus. So if the mouse pointer was in the phone number field and the user clicked the Search button, it would let them search on phone number. They could click on the name field, for example, and the search window would change to a name search.

For separate buttons that always allow searches on the same fields, you'll have to modify the code that the wizard generates. Edit the event procedure, and where it says this:Screen.PreviousControl.SetFocus

substitute this:

Form.Controls("myControlName").SetFocus

where "myControlName" represents the name of the form control that's bound to the field you want this button to search on.

I hope this does what you want.

Steve Diamond

Collapse -

Access 2000

by sivickers In reply to Access 2000

Sorry again. I have seen a database that had macro's to do the search commands. All I am trying to find out is how to setup these macro's to do this

Collapse -

Access 2000

by joescalia In reply to Access 2000

Sounds like you are looking for a marco with command buttons on the form to activate the marco . You can create a switchboard form.This allows you to access the form more covenentily. Once you create the form then you can add in your command buttons. You then can filter your data by using parameters and form filters.
I hope I gave you a starting point.
Good Luck

Collapse -

Access 2000

by sivickers In reply to Access 2000

Yes that is what I am trying to do but how do you start to do the macro's? I can do the basic ones like opening up and printing records from a form but how do you set up a macro to do a search?

Collapse -

Access 2000

by parier In reply to Access 2000

This isn't really a macro, but a push button instead.

In the Access Database window click the "Queries" tab and then click "New". Select "Design View" and OK from the New Query window. Double click on the Table containing whatever it is you wish to report on and then Close the Show Table window. Drag or double click on each field you want in your report. In the query column that contains the data you are searching on enter the following in the Criteria: space "[Forms].[,your table name here].[your search box name here]". Click the "Exclaimation mark" in the toolbar to run the query and manually enter a value from your search box to see if everything works. If so save and name your query, and base your report on it. Once your form is open the Criteria you entered above will automatically find whatever the user selects in your search box!


Hope this helps!

Collapse -

Access 2000

by sivickers In reply to Access 2000

yeah thanks that did it

Back to Software Forum
13 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums