Many queries to same form?

  • Thread starter Thread starter an
  • Start date Start date
A

an

Hello!
Is possible to choose more than one query to "feed" a same
form, please?
Thanks in advance.
an
 
You'll need to be more specific about what you want to do. It's possible to
change the RecordSource of a form from one query to another; it's possible
to use various subforms, each with its own RecordSource. And perhaps other
ways to do what it sounds like you want to do.
 
Thanks for your reply.

The situation is:
I had necessity to appeal of crosstabqueries to command
given for monthly graphs. The intention would be not to
have one form, or subform, for each month of each year but
only one form and the user, when choosing the month,
loaded corresponding query.
Is it possible?

an
 
I think so, if I'm understanding your question.

You could have a form open that asks the user which month to use. The user
enters (or selects in a combo box) the desired information, and the clicks a
button on that form. The form then runs code to open the form that will
display the data, and the form passes to the "data display" form the query
that is to be used as the second form's Recordsource. This passing is done
via the OpenArgs argument of the DoCmd.OpenForm action. The second form
reads the OpenArgs value and uses it to set the RecordSource.

For the button on the first form, assuming that the user selects a month
from the combo box and that the combo box's value is 1, 2, 3, etc.
corresponding to the month:

Private Sub CmdButtonName_Click()
Dim strQueryName As String
strQueryName = Choose(Me.ComboboxName.Value, "JanuaryQuery",
"FebruaryQuery", _
"MarchQuery", "AprilQuery", "MayQuery", "JuneQuery", "JulyQuery",
"AugustQuery", _
"SeptemberQuery", "OctoberQuery", "NovemberQuery", "DecemberQuery")
DoCmd.OpenForm "NameOfSecondForm", OpenArgs:=strQueryName
End Sub


The code in the second form's Load event would be something like this:

Private Sub Form_Load()
Me.RecordSource = Me.OpenArgs
End Sub

--

Ken Snell
<MS ACCESS MVP>
 
Sorry for my delay.
I think understood your idea, although complex for my
little knowledge.
I'm go to try.
Many thanks.
an
-----Original Message-----
I think so, if I'm understanding your question.

You could have a form open that asks the user which month to use. The user
enters (or selects in a combo box) the desired information, and the clicks a
button on that form. The form then runs code to open the form that will
display the data, and the form passes to the "data display" form the query
that is to be used as the second form's Recordsource. This passing is done
via the OpenArgs argument of the DoCmd.OpenForm action. The second form
reads the OpenArgs value and uses it to set the RecordSource.

For the button on the first form, assuming that the user selects a month
from the combo box and that the combo box's value is 1, 2, 3, etc.
corresponding to the month:

Private Sub CmdButtonName_Click()
Dim strQueryName As String
strQueryName = Choose
(Me.ComboboxName.Value, "JanuaryQuery",
 
Back
Top