If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Using forms to print reports based off of queries
I have a couple of reports that pull their information off of a single query
and want to know if a form can add a filter to the query results for the reports. i.e. I have a sales query and I have a form that the user selects the month and it will print out the sales report for January. |
#2
|
|||
|
|||
Yes. Replace your query criteria with...
=Forms![MyFormName]![MyFieldName] -- Rick B "Keith Meier, MCSA" wrote in message news I have a couple of reports that pull their information off of a single query and want to know if a form can add a filter to the query results for the reports. i.e. I have a sales query and I have a form that the user selects the month and it will print out the sales report for January. |
#3
|
|||
|
|||
Rick gave you one way, another way will be
when you give the command to print you can add the filter ' incase the field is number type docmd.OpenReport "ReportName",acViewPreview,,"[MyFieldInQuery]= " & me.[MyFieldOnform] ' incase the field is text type docmd.OpenReport "ReportName",acViewPreview,,"[MyFieldInQuery]= '" & me.[MyFieldOnform] & "'" "Keith Meier, MCSA" wrote: I have a couple of reports that pull their information off of a single query and want to know if a form can add a filter to the query results for the reports. i.e. I have a sales query and I have a form that the user selects the month and it will print out the sales report for January. |
#4
|
|||
|
|||
That way you can print the same report for several of forms, it doesnt limit
you to one form. "Keith Meier, MCSA" wrote: I have a couple of reports that pull their information off of a single query and want to know if a form can add a filter to the query results for the reports. i.e. I have a sales query and I have a form that the user selects the month and it will print out the sales report for January. |
#5
|
|||
|
|||
Thank you,
Is there a way to create a control that would export the results of a query into Excel? Thanks again in advance, Keith "Ofer" wrote: Rick gave you one way, another way will be when you give the command to print you can add the filter ' incase the field is number type docmd.OpenReport "ReportName",acViewPreview,,"[MyFieldInQuery]= " & me.[MyFieldOnform] ' incase the field is text type docmd.OpenReport "ReportName",acViewPreview,,"[MyFieldInQuery]= '" & me.[MyFieldOnform] & "'" "Keith Meier, MCSA" wrote: I have a couple of reports that pull their information off of a single query and want to know if a form can add a filter to the query results for the reports. i.e. I have a sales query and I have a form that the user selects the month and it will print out the sales report for January. |
#6
|
|||
|
|||
Yes, you can choose it in your toolbar.
right click on the tool bar, choose customise, commands, choose tools there youll see few commands, one of them is anlayse with excel, or word and more "Keith Meier, MCSA" wrote: Thank you, Is there a way to create a control that would export the results of a query into Excel? Thanks again in advance, Keith "Ofer" wrote: Rick gave you one way, another way will be when you give the command to print you can add the filter ' incase the field is number type docmd.OpenReport "ReportName",acViewPreview,,"[MyFieldInQuery]= " & me.[MyFieldOnform] ' incase the field is text type docmd.OpenReport "ReportName",acViewPreview,,"[MyFieldInQuery]= '" & me.[MyFieldOnform] & "'" "Keith Meier, MCSA" wrote: I have a couple of reports that pull their information off of a single query and want to know if a form can add a filter to the query results for the reports. i.e. I have a sales query and I have a form that the user selects the month and it will print out the sales report for January. |
#7
|
|||
|
|||
I was hoping to integrate the export into the command that adds the filter to
the query... i.e. click export sales report button in form, it will create the query and the next screen the user sees is the window to save the file. "Ofer" wrote: Yes, you can choose it in your toolbar. right click on the tool bar, choose customise, commands, choose tools there youll see few commands, one of them is anlayse with excel, or word and more "Keith Meier, MCSA" wrote: Thank you, Is there a way to create a control that would export the results of a query into Excel? Thanks again in advance, Keith |
#8
|
|||
|
|||
create an empty query called GlobalQuery, now you can try that code
Function aaaaa() Dim DBS As Database Dim rst As Recordset, SqlStr As String Set DBS = CodeDb SqlStr = "SELECT * FROM MyTable WHERE " & TheFilterFromTheReport DBS.QueryDefs("GlobalQuery").SQL = SqlStr ' Transfer the query we created to c: drive DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel3, "GlobalQuery", "c:\GlobalQuery.xls" ' The location to save to can be a parameter pass to the function. End Function "Keith Meier, MCSA" wrote: I was hoping to integrate the export into the command that adds the filter to the query... i.e. click export sales report button in form, it will create the query and the next screen the user sees is the window to save the file. "Ofer" wrote: Yes, you can choose it in your toolbar. right click on the tool bar, choose customise, commands, choose tools there youll see few commands, one of them is anlayse with excel, or word and more "Keith Meier, MCSA" wrote: Thank you, Is there a way to create a control that would export the results of a query into Excel? Thanks again in advance, Keith |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sorting values in reports based on crosstab queries. | jsccorps | General Discussion | 2 | November 10th, 2004 05:45 AM |
Organizing Queries and Reports | Suzanne Knapp | Running & Setting Up Queries | 6 | October 12th, 2004 02:59 AM |
saved queries based on other saved queries vs. one big query in a form's module using DAO | Richard Hollenbeck | Running & Setting Up Queries | 5 | September 23rd, 2004 08:38 PM |
Forms: based on query vs. based on table | Using Forms | 1 | August 13th, 2004 02:17 AM | |
Reports created from forms | CRAIG KELLY | Database Design | 1 | May 21st, 2004 01:32 AM |