View Full Version : Query results into a form


TStock
06-02-2001, 11:12 AM
I am trying to enter criteria for a query in a form and have the results returned to the same form dynamically

Thank to anyone that can help

T

Fornatian
06-04-2001, 08:15 AM
You need to

1. build a standard form which will show the results
2. go to design view
3. add a text box from the toolbox to the form, this is where the user will enter criteria. This is known as an unbound control because it is not bound to any table, like the other text boxes on the form.
4. give the textbox's label a suitable caption and place it in a suitable place on the form.
5. go to the textbox's properties and change it's name to 'txtMyCriteria'
6. save the form as "MyForm"(or any other name you fancy.)
7. go to design view in a new query
8. add the table that the form was based on to the design grid, include each field as a column
9. under the fields column that you want to add as criteria insert this:
Like "*" & [Forms]![MyForm]![txtMyCriteria] & "*"
**Swap 'MYFORM' for the name of your form.
10. add a button to the form and in the code behind insert:
Me.Requery
11.Change the recordsource of the form to point at the query.
12. Test it!

13. If it works, pat yourself and me on the back!
14. If not write back...

HTH

Ian