Macro to run reports based on query criteria

so be nice
I've got a bit of a macro problem, I'm looking to create a macro which will input criteria, by which reports can be created. I have a report based on a query which asks for the department code, to return all the access data for the department.
I want to create a macro which will create and print a report for each of the departments, by automatically entering the department codes.
Any ideas? Any more detail needed

Sponsored Links:

Related Topics

Criteria for Report/Query being ignored
I have a report with a record source based on a query that has certain criteria that must be met in a particular field. However, this criteria is being ignored in 4 of the 5 reports. These five reports are similar except that they are dividing all the records up into the five separate reports based on this one field. The only one that is working, is the one whom's data is showing up on the other four reports.

Do I need to show more, or can anyone tell what is going on here? All five reports have their own separate record source.

I have a feeling I might have to explain more


Setting up Macro on Criteria filtered Querry
I have a query that includes a Date/Time field. Currently each time we need to run it we have to change the criteria; for example - Like "*03/05/2012*" to Like "*03/05/2012*", to get query only the data for today.

I have not seen a way to use the Like function and the Date() in the same criteria. Normally not an issue to change it, but it has became evident that we need to run this query very late in the evening, and I need a macro to set the Windows schedule to run it. So need a way to either get the query to only pull today's date, or a macro to change the criteria when it auto launches as scheduled.

A bit of a noob to access, and working with a database that someone else built.


access 2007 macro
I have built 12 queries that obtain data from the same 2 tables but for 12 different reports. I have created 12 separate reports as well. I want to run all 12 queries/reports at once. I have set up a filter in which I enter 'from' and 'to' dates, but I have to do this for each query/report. I want to build a macro that will run all 12 reports at once, and all I'll have to do is manually enter the dates one time at the beginning of the macro. I can not get the date filter at the beginning of the macro to operate successfully - keep getting error message. Where can I get good resource data that will help me with this macro? The Microsoft online help doesn't cut it


access 2007 macro
I have built 12 queries that obtain data from the same 2 tables but for 12 different reports. I have created 12 separate reports as well. I want to run all 12 queries/reports at once. I have set up a filter in which I enter 'from' and 'to' dates, but I have to do this for each query/report.

I want to build a macro that will run all 12 reports at once, and all I'll have to do is manually enter the dates one time at the beginning of the macro.

I can not get the date filter at the beginning of the macro to operate successfully - keep getting error message. The Microsoft online help doesn't cut it.


Automating multiple reports with a macro that prompts user for a date range
A database that I created has a main query that includes a lot of calculations of data that it pulls from a main table. The main query prompts the user for a date range with a "Between [start date] And [end date]" request in the Criteria for the "Date" field.

I have also created many secondary queries that get their data from the calculated fields in the main query.

Finally, I have created about a dozen individual reports that are based upon each of these secondary queries.

I have automated the process of running these reports with a macro that executes the "OutputTo" action a dozen times to save each report as an individual Rich Text file. Theproblem I have is that, when I run the macro, it asks me for the [start date] and [end date] a dozen separate times.

Is it possible to modify the macro to prompt the user one time for the start and end dates and then to pass those dates on to each individual report/query? Or do I need to try to do this with a VBA module?


Macro Creation
I have my report built and is tied to a query. Some background on this: I need to send out approval reports to supervisors for telecom bills. The query is built so that no criteria is specified in the Approver field.

I want to build a macro that will process all approvers, one at a time, and generate reports to the snapshot viewer.

I am pretty new to access and I am not familiar with VB or XML coding. I have the macro built for the first record, but I don't know how to "do until end" type scenario.

Can this be done using the macro actions and not writing code? I am on Access


Variable Not passing to query
I have a command button which when clicked, runs a VBA macro which saves a report to a PDF for the current record. The report is based on a predefined filter for based on the current ID field on the original form.

I have tried setting the criteria field to the current record of the form, setting a variable to the ID field. But the query is not getting the information to compare and the output of thereport is #Type and #Error.

When the macro is run, the query runs and prompts for the information the criteria is looking for.

How do I pass a variable from a form to a query in VBA?


Can I manipulate a query for a few different reports?
I have a query that I would like to base several reports off of. Can I add parameters to the reports so I won't have to have the same query done several times just to change the parameters of what I am looking for?

For example, my database has several different craft codes and ideally what I would like to happen is to be able to use that same query to change the craft codes each time, or skill set. As of right now, I have the same query run with different criteria for each query.

It is the same idea for several reports that I will be running for my executives.


Find and Replace Within a Macro
I have a large macro with a lot of actions to run reports and export them to a shared drive. I basically need to copy the macro, but make it run a different query/report. Is there any way to do a find and replace to change the query and report name within the macro in one step, opposed to going through all the action lines and changing it? This would save me a lot of time.


Run macro from combobox NOT based on selection
Is it possible to call/run a macro from a combobox but it is NOT based on the combobox selection?

I know you can do it based on the combobox selection but that is not what I want. I have the user make a selection from the combobox and store it as a variable under the afterupdate event criteria. Within that same afterupdate event, I want to close the form and run a macro that will allow the user to select a file using the API command dialog box.

I have the command dialog box macro runnig fine and can call it from a button with no problem. Just need to be able to call it from within a combo box.


Is Grouping or Criteria Applied first?
In an Access Query, which is applied first: Grouping or Criteria?

I am trying to run a query whose results could potentially differ depending on whether the query's data set is grouped, then filtered based on criteria or filtered based on criteria, then grouped.

(i've done a little testing and it looks like criteria is applied first but I wanted to be sure


Automation of running macro
currently I am modifying a access program. My program is to store some data (of course :P ) and to export the table into excel file for report generation. There are lots of them and now I want to automate this procedure by just clicking one button.

This is what I have to do before the modification for generating reports:
1.Run the make table query and save it as excel format somewhere.
2.open the macro workbook
3.choose the correct macro and run it

I tried:
Add RunApp in macro to run the macro workbook
Modified the code ( actually I am very new with this, so I do not know to do it)

so would you please give me some suggestion or direction to solve the problem


Query Criteria
On my query I added criteria that says [Forms]![frmMain]![Combo11] so that the query will run based on what is selected from the drop down. However, if the drop down is left blank (no select made). How would I update my criteria to say than display all?


When a query result is empty
So I would like to pose it here. I have a simple query that returns data based on entering a specific criteria.

The query is run from a macro and the results get created in a spreadsheet and emailed to certain people. The problem I have is that if the query returns no data, for whatever reason, then I don't wish the spreadsheet to be created or emailed.

So, in basic terms, if I enter criteria that is spelt incorrectly or the data doesn't exist, I want the query to error and tell me why. Is this something easy to achieve.?


Append query runs on its own but not in a macro
A database I created for a client some years ago has a macro which contains an append query. This macro repeats itself until a condition is met and has run thousands of times without any problem.

The client has asked that I make the database work for multiple factories. Without going into too much detail the same macro and append query are needed in the spin-off databases (one for each factory).

The problem is that the append query will not run in any of the spin-off databases as part of the macro although the macro itself is unchanged, but will run in isolation when it performs correctly and gives no error messages. I have run the macro with SetWarnings ON, but only get the warnings that you would normally expect.

I have pasted over the macro, the append query and the underlying select queries from the original database, but to no effect.


When a query result is empty.....
I have been searching the net for an answer but I am not sure of the right question.so I would like to pose it here. I have a simple query that returns data based on entering a specific criteria. The query is run from a macro and the results get created in a spreadsheet and emailed to certain people. The problem I have is that if the query returns no data, for whatever reason, then I don't wish the spreadsheet to be created or emailed. So, in basic terms, if I enter criteria that is spelt incorrectly or the data doesn't exist, I want the query to error and tell me why. Is this something easy to achieve


RunMacro Macro Action
You can use the RunMacro action to run a macro. The macro can be in a macro group.
You can use this action:
-To run a macro from within another macro.
-To run a macro based on a certain condition.
-To attach a macro to a custom menu command.


Asking For Parameters Twice
I am trying to run a report based upon query results. The criteria for the query are set via parameters so that when you run the query, the box "Enter Parameter Value" box comes up.

The problem is that this box requesting parameters comes up when you run the report as well. That is a problem because I have a macro built to run the query, then the report and this makes it so that each parameter has to be entered twice.

Is there any way to stop Access from asking for the parameters before the report is created?


Summing Values of a Subquery
I am working on building a series of queries and reports based on a database so my associates can simply click on the reports and get important figures. I've run into a problem when it comesto aggregates based on a query with a subquery in it.

I'm used to using PHP and MYSQL to run queries and manage databases, so I'm new to Access syntax and limitations. I'm building these reports in Access 2010.

An example of the issue I'm running into can be seen with this query:


Pass information from form to QUERY CRITERIA
I have a macro [mcPO] that executes when I click on a command button [Issue Purchase Order]. This macro saves and closes a form [frmPO_ISSUE] and then opens a report [rptPO].

rptPO is based on a query [qryPOCopy].

When qryPOCopy is run, a pop-up window appears asking for a PO Number ( Criteria = [Enter PO Number:] ). Then it searches two tables [tblPOHIST and
tblBUYHIST] to find the information it needs to create the report.

Since the PO number [text box name: P_O_NO] I want to use for the report/query is in the form that I am save/closing, can I pass that information automatically to the query by either adding some code to the ON CLICK event of my command button [Issue Purchase Order] or by adding to the macro that calls the report?