13 replies
by steved
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
by sivickers
by lo
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
by sivickers
by steved
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
by sivickers
by joescalia
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
by sivickers
by parier
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!
by sivickers
If I read you correctly, macros won't do the job. What you need is a command button, a text box and a combo box. Put them in the form header.
In the combo box, list the fields you want to search on, e.g. LastName, Phone, etc.
Set the default value to the most frequent field searched. Call it cboField.
Call the text box txtFind
Display the text box's property sheet and find the AfterUpdate event. Click into the text entry area and click on the build button [...] which appears.
In the text box's AfterUpdate event complete the following code
Private Sub txtFind_AfterUpdate()
DoCmd.ApplyFilter "[" & Me.cboField & "] Like '" & Me.txtFind & "*'"
End Sub
Call the command button cmdShowAll
In the button's OnClick event procedurecomplete the following code:
Private Sub cmdShowAll_Click()
DoCmd.ShowAllRecords
End Sub
On the Debug Menu click Compile There may be errors, check your typing and if that's not the problem, contact me through Peers.
Click the save button and on the file menu click Close and return to Micrsoft Access.
By entering text in txtFind and pressing enter you the form will filter out the records matching whatever is input.
Clicking the button will remove the filter and show all records.
Note that the * in the SQL statement in txtFind_AfterUpdate allows you to enter the first few letters of a name. For example typing the letter J will return all records with the selected field beginning with J, JO will bring up all Js with O as the second letter, etc. Also it's not case sensitive.
Hope this helps
by sivickers
by sivickers
This discussion is closed to new replies.
Trending Software posts
Sort by Trending