Creating a button that takes a text input and passes it to a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'm creating an internal ordering system for the company I work for.

Within this database I have a quotation database and an ordering system. I
am in the midst of setting up the order system and have a field which is used
for entering the reference number of the relevant quotation. I want next to
this field a button, which when clicked, takes the ref# entered in the
quotationRef field and then passes that onto my query which will then load
the relevant quotation's report.

So what's the code for the button which will pass the field's contents to
the query?
 
Richard

You don't even need to use code to "pass" the value.

You can modify your query to refer to the form that holds your "ref#" (you
may want/need to use square brackets around that name, as the special
character "#" may cause problems -- or you can change the name to "refno" or
some such). In the criteria row under the reference number field, you'd use
something like:

Forms!YourFormName!YourControlNameThatHoldsRefNo

On the button click, open your report based on the query.

Alternatively, take a look at Access HELP on:

DoCmd.OpenReport,,,,

The syntax of this command includes a way to set a WHERE condition, which
you could use to filter down the report to the single RefNo you are after.
You'd still need to pass the value of the RefNo control into this line of
code...
 
Back
Top