473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need help on creating macro to print reports sequentially

8
I have 3 reports that I need to print sequentially, situation is this

R- Report
P-Person

R1 has 3 pages, one for each P
R2 " "
R3 " "

I would like to be able to print R1P1,R2P1,R3P1..., then do the same thing for each subsequent person.

Any guidance or direction is greatly appreciated. I tried to build a macro in to the detail section of the report to run another macro, but it failed.

thanks in advance
jm
Jul 23 '08 #1
2 2016
Stewart Ross
2,545 Expert Mod 2GB
Hi, and welcome to Bytes!

It is possible but not straightforward to do as you ask. You will need to use VBA code to do so outside of the reports; this is not a task which can be accomplished from within.

You have three independent reports, and you wish to output the pages relevant to each user in turn. You will need to devise a query based on your report's underlying query which extracts the user ID or name of the users involved. In VBA code called from the On Click event of your command button running the report you then need to loop for each user and print each report in turn, filtered for that user only.

A skeleton of the code using dummy field and query names is shown below.

Expand|Select|Wrap|Line Numbers
  1. Dim RS as DAO.Recordset
  2. Dim userid as String
  3. set RS = CurrentDb.OpenRecordset("name of your username query")
  4. do while not RS.EOF
  5.   userID = RS![your user ID field name]
  6.   DoCmd.OpenReport "R1", acViewNormal, "[your user ID field name] = " & UserID
  7.   DoCmd.OpenReport "R2", acViewNormal, "[your user ID field name] = " & UserID
  8.   DoCmd.OpenReport "R3", acViewNormal, "[your user ID field name] = " & UserID
  9.   RS.Movenext
  10. Loop
  11. RS.Close
This uses a Data Access Object (DAO) recordset. Check in the VB editor that you have a reference to the DAO object library set already - select Tools, References and ensure that Microsoft DAO 3.6 or later object library is ticked. If you do not the code will not compile.

There is one other alternative that is much simpler, but I doubt if it is suitable in your case. That is to include R2 and R3 at the bottom of R1's detail section as subreports, linked parent/child by user ID or name. I doubt that this will be suitable because the formatting of the reports is unlikely to match sufficiently when constrained from within another report, but there is no harm in trying it out to see if it works. It is much easier than the code-based solution, but less flexible.

-Stewart
Jul 24 '08 #2
JM420A
8
Stewart,
Option 2 worked. I tried doing that before I asked and it didn't work. Must be one of those "Take the car to the mechanic so the noise stops issues"

I'll probably post more

You answered my question, thanks

jm420a
Jul 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
0
by: Ian | last post by:
(Sorry if I have repeated this, it did not appear the first time) I have the following code on a button. The idea is that when this button is clicked it prints several reports automatically then...
4
by: italiak | last post by:
Hello everyone- I have these 500 queries in access. They all do the same thing (append data from big database to a table) and have similar condition. I was wondering if there is a way I can...
1
by: Jo K. | last post by:
I have the following fields in a table. -JobNo (primary key) -Assessor (combo box containing only two names to choose from ie. John, Bill) I have created two seperate reports which have exactly...
1
by: grumpyone | last post by:
I'm looking for a method to enter and retain a start date and end date for use with a macro that runs 11 month-end reports that each require the same start date and end date. FYI- currently, the...
0
by: modularmix | last post by:
Does anyone know how to run the Excel Macro for two different spreadsheets in parallel. Here is the code that works sequentially. Workbooks.Open Filename:="C:\Documents and...
9
by: Martian7 | last post by:
Hello, I have been having a problem with my database lately. Everything seems to be working well accept the reports. Everytime I open the report I have to reformat the report margins to get...
1
by: awojciehowski | last post by:
Greetings: I have been working on a database and have found a peculiar error. When I open up my database and choose a form called "add inventory", then click on "view reports" and then,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.