Double Query into a Form

  • Thread starter Thread starter Mo
  • Start date Start date
M

Mo

Hi,

We currently have a query in (Access 2000) where, it will
ask for a Month and a Name from the same table. But i
would like to display the results in a form and if
possible allow users to choose the Month and Name from a
dropdown list and then click on a button to run the query
within the form.

I am not sure if this is the best way, but any suggestion
and how to setup the forum would be appricated.

Cheers

M
 
Mo,

Here's one approach of a number of possibilities: On your form, you
could put two unbound comboboxes, with their Row Source properties set
up as a table or query, as applicable, to show the list of months and
names. You then enter the criteria in there, and in the query, instead
of the parameter prompts that you currently have there in the query
criteria, you would put a reference to the comboboxes, using syntax such
as...
[Forms]![NameOfYourForm]![NameOfYourCombobox]

If the form that you use to display the results of the query is the same
form as the one where you have these criteria comboboxes, you will need
to Requery the form after the criteria are entered.

By the way, as an aside, I'm not sure if your post implied that your
fields are called Month and Name, but if so, this is not a good idea.
Both these words are 'reserved words' (i.e. have a special meaning) and
should not be used as the name of a field or control.
 
Hi,

We currently have a query in (Access 2000) where, it will
ask for a Month and a Name from the same table. But i
would like to display the results in a form and if
possible allow users to choose the Month and Name from a
dropdown list and then click on a button to run the query
within the form.

I am not sure if this is the best way, but any suggestion
and how to setup the forum would be appricated.

The simplest way to do this is to create a small form (let's call it
frmCrit) with the controls you want to use as the criteria - I'll call
them cboMonth (returning 1 to 12) and cboName (returning a text name).

You can then create a query with criteria on the date field of:
= DateSerial(Year(Date()), Forms!frmCrit!cboMonth, 1) AND < DateSerial(Year(Date()), Forms!frmCrit!cboMonth + 1, 1)

and on the name field of

= [Forms]![frmCrit]![cboName]

Put a command button on frmCrit to open a separate form (or Report)
based on this query.
 
Back
Top