A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using forms to print reports based off of queries



 
 
Thread Tools Display Modes
  #1  
Old May 16th, 2005, 07:25 PM
Keith Meier, MCSA
external usenet poster
 
Posts: n/a
Default 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  
Old May 16th, 2005, 07:28 PM
Rick B
external usenet poster
 
Posts: n/a
Default

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  
Old May 16th, 2005, 07:48 PM
Ofer
external usenet poster
 
Posts: n/a
Default

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  
Old May 16th, 2005, 07:51 PM
Ofer
external usenet poster
 
Posts: n/a
Default

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  
Old May 16th, 2005, 10:21 PM
Keith Meier, MCSA
external usenet poster
 
Posts: n/a
Default

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  
Old May 16th, 2005, 10:59 PM
Ofer
external usenet poster
 
Posts: n/a
Default

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  
Old May 17th, 2005, 03:15 PM
Keith Meier, MCSA
external usenet poster
 
Posts: n/a
Default

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  
Old May 17th, 2005, 07:06 PM
Ofer
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 11:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.