Enter parameters from a form then run the query

  • Thread starter Thread starter karaeloko
  • Start date Start date
K

karaeloko

Hi,

I have this query

SELECT tblPst.Field2
FROM....
WHERE (((tblPst.Date) Between [Enter start date:] And [Enter end
date:]))
GROUP BY tblPst.Field2
ORDER BY tblPst.Field2,

I want to be able to open the form and not have to enter the values in
the pop-
ups, but instead choose the dates from calendar controls for "Enter
start date:" and "Enter end date:" and then run the query with a
command button.

Thanks for the help provided.
 
Hi,

I have this query

SELECT tblPst.Field2
FROM....
WHERE (((tblPst.Date) Between [Enter start date:] And [Enter end
date:]))
GROUP BY tblPst.Field2
ORDER BY tblPst.Field2,

I want to be able to open the form and not have to enter the values in
the pop-
ups, but instead choose the dates from calendar controls for "Enter
start date:" and "Enter end date:" and then run the query with a
command button.

Thanks for the help provided.

Change your criteria from

[Enter start date:]

to

[Forms]![NameOfYourForm]![NameOfYourControl]

It's also very likely that you do NOT need to or want to actually "run the
query" at all! Instead, base a Form (for onscreen viewing) or Report (for
printing) - or both - on the query, and have a button on the criteria form to
launch THAT.

John W. Vinson [MVP]
 
Thank you for your reply.

You're right. That's kind of what I need.

I have a subform to display the query. What I need is to be able to
enter the parameters in the main form to then run the query in the
subform. I can't figure out how to stop the subform query from running
when I open the form.
 
Thank you for your reply.

You're right. That's kind of what I need.

I have a subform to display the query. What I need is to be able to
enter the parameters in the main form to then run the query in the
subform. I can't figure out how to stop the subform query from running
when I open the form.

Well... *don't run the query AT ALL*.

Just set the Subform's Recordsource property *to the query*. Requery the
subform in the afterupdate events of the mainform parameter controls; or, base
the Subform on a query which doesn't have these parameters at all - instead,
set the Master Link Field property of the subform to

[ControlName1];[ControlName2]

and the Child Link Field to the names of the linking fields in the subform's
table.

John W. Vinson [MVP]
 
Back
Top