|
Adding a Search Control to a Form
From NeoWiki
This article is part of the To Base and Back Again tutorial series.
In addition to using form-based filters, you can also create a control on a form that will allow the user to quickly filter the data according to the control setting. As an example of this, we will create a combo box on our All Sightings form to filter by the StateOrProvince field. The process for creating a search control with a text box or a list box is very similar.
Add An Alias to the All Sightings Query
In the process of testing this approach, I discovered that the field name StateOrProvince was problematic. The macro described later in this article read this name as two field names separated by the logical operator "OR", and threw an SQL error. Fortunately, this issue was easily solved by creating an alias for the field in question.
- Open the All Sightings Query for editing (In the main database document, click on Queries in the left hand column, then right-click or control-click on the All Sightings Query and choose Edit from the contextual menu)
- In the Alias row of the StateOrProvince column, type State
- Click the Save icon on the toolbar, or hit Command-S
- Close the Query
Adding the Control to the Form
- Open the All Sightings Form for editing (In the main database document, click on Forms in the left hand column, then right-click or control-click on the All Sightings Query and choose Edit from the contextual menu)
- Right-click or control-click on the State column heading and choose Column... from the contextual menu.
- In the {{Section|Tab} of the Properties: Text Box window, replace StateOrProvince with State
- Close the Properties: Text Box window.
- Note the steps above are not normally part of creating a search control. They are necessary here because we created the Alias for the StateOrProvince field after the form was built.
- If the Form Controls toolbar is not visible, go to the View menu and choose Toolbars an then Form Controls.
- Click on the Combo Box form control on the toolbar
- On the form, drag to create a Combo Box in the space between the title and the table.