What I want to do is enter parameter for a query within a form then run the query and display the result in a form (the same or a new form)
How can I do that ?
put an unbound textbox on your exsisting form (which is based on the query) called [param] (for instance) this will hold your parameter it can be a combo box that looks up data if you wish or just a box that peple type in
now goto the macros tab
click add new
type REQUERY in the first line
save it as REFRESH
go back to your form
in the After Update event of the text box select REFRESH
the with re-run the query every time you press return in the text box
then in you query set that textbox as the parameter
eg.
=[forms]![myformName]![param]
There is another way of doing this, very similar..
create an unbound text box and name it 'querybox' on your existing form (which will most likely be based on a query)
now open up the query that your form is based on:
if for example it is based on addresses of people you know etc.. and you wanted to find the address based on their 'postcode', then in the 'postcode' fields criteria section, you would type the following
like [forms]![yourformname]![querybox]
the ![querybox] bit is telling your query to check what is written in the textbox called 'querybox' on your form called 'yourformname'.
then, go into the design view of your form and select your new textbox 'querybox' and in the afterupdate event click on the three '...' that appear on the end. select the 'third' option 'code' and type in the following VBA bit.
DoCmd.Requery "the name of the query that your form is based on"
save and exit the code window, save the form and voila, your form will bring back details based on what you type in the text box.
Their is an addition to this, your textbox can bring you back records based on anypart of the address.
going back to editing the query that your form is based on, the postcode field criteria being
like [forms]![yourformsname]![querybox]
that would be the first thing that your query looks for. on the next line down, say in the 'address line 1' field, in the 'OR' section, you would put exactly the same criteria
like [forms]![yourformsname]![querybox]
your query would then look in the 'postcode' like the one you typed in the textbox 'querybox' or look at the 'address line 1' field for matching text.
It's up to you what you do from there!
If this has been of any help, then please let me know.
Using the above query, I was able to develop a phone list that would find anyone, anywhere!
and it's quick because it doesn't refer to other parts like macros 'not that there is anything wrong with them!!!'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.