Sending Search Parameters to a Query Through a Form

S

silva

I am wanting to display a report that shows transactions for a certain month.
The report is complete, and needs no work. However, I want to be able to
choose the parameters that define what it displays from a form. The idea is
to display records for an entire specific month froma defined year. The month
and year would be selected from a drop-down box. I was planning on having the
values displayed in each drop-down sourced from tables built specifically for
those values. How would I code a command button to do this?

The current format of the data in the date field is mm/dd/yyyy hh:mm. I
would use a field named [month] and one named [year] on the form.
 
F

fredg

I am wanting to display a report that shows transactions for a certain month.
The report is complete, and needs no work. However, I want to be able to
choose the parameters that define what it displays from a form. The idea is
to display records for an entire specific month froma defined year. The month
and year would be selected from a drop-down box. I was planning on having the
values displayed in each drop-down sourced from tables built specifically for
those values. How would I code a command button to do this?

The current format of the data in the date field is mm/dd/yyyy hh:mm. I
would use a field named [month] and one named [year] on the form.

If you wish to use 2 combo boxes for the user to select the month and
year from, code a command button's click event on the form:
DoCmd.OpenReport "ReportName",acViewPreview, , "Year([DateField]) = "
& Me.YearCombo & " and Month([DateField]) = " & Me.MonthCombo
 
S

silva

Excellent! Thank you! It works great. One more question, though. Is there any
way I can get the search parameters to display on the report? For example,
have a page header that says "Summary for 'Month' 'Year' ".

fredg said:
I am wanting to display a report that shows transactions for a certain month.
The report is complete, and needs no work. However, I want to be able to
choose the parameters that define what it displays from a form. The idea is
to display records for an entire specific month froma defined year. The month
and year would be selected from a drop-down box. I was planning on having the
values displayed in each drop-down sourced from tables built specifically for
those values. How would I code a command button to do this?

The current format of the data in the date field is mm/dd/yyyy hh:mm. I
would use a field named [month] and one named [year] on the form.

If you wish to use 2 combo boxes for the user to select the month and
year from, code a command button's click event on the form:
DoCmd.OpenReport "ReportName",acViewPreview, , "Year([DateField]) = "
& Me.YearCombo & " and Month([DateField]) = " & Me.MonthCombo
 
J

John W. Vinson

Excellent! Thank you! It works great. One more question, though. Is there any
way I can get the search parameters to display on the report? For example,
have a page header that says "Summary for 'Month' 'Year' ".

You can put textboxes on the form with Control Sources like

=[Forms]![yourformname]![controlname]

to do so.
 
S

silva

It sounds like you're talking about displaying information from one form on
another form. I have combo boxes on a form being used as parameters for a
query to display specific information on a report. I would like to be able to
display the parameters sent to the query on the report itself. How do I
display those parameters? I know how it works when the parameters are entered
in a message box, but not when they are passed along from a form.

John W. Vinson said:
Excellent! Thank you! It works great. One more question, though. Is there any
way I can get the search parameters to display on the report? For example,
have a page header that says "Summary for 'Month' 'Year' ".

You can put textboxes on the form with Control Sources like

=[Forms]![yourformname]![controlname]

to do so.
 
J

John W. Vinson

Minor typo on my part. You can put textboxes on the *REPORT* with Control
Sources like

=Forms!yourformname!controlname

to display the parameters on your report.
It sounds like you're talking about displaying information from one form on
another form. I have combo boxes on a form being used as parameters for a
query to display specific information on a report. I would like to be able to
display the parameters sent to the query on the report itself. How do I
display those parameters? I know how it works when the parameters are entered
in a message box, but not when they are passed along from a form.

John W. Vinson said:
Excellent! Thank you! It works great. One more question, though. Is there any
way I can get the search parameters to display on the report? For example,
have a page header that says "Summary for 'Month' 'Year' ".

You can put textboxes on the form with Control Sources like

=[Forms]![yourformname]![controlname]

to do so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top