473,545 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Batch Printing Reports

Missionary
30 New Member
I need to batch print reports. I've looked at past posts about batch printing, but I don't know visual basic, so I'll need some coaching.

I have a report based on a parameter query. I have it set to take the parameter value from a form that I use to preview and print reports.
I have to repeatedly print that report using a different value each time. I want to set it up to batch print, taking the values from a list in a table.

Thanks for your time
Feb 20 '08 #1
22 8929
jaxjagfan
254 Recognized Expert Contributor
I need to batch print reports. I've looked at past posts about batch printing, but I don't know visual basic, so I'll need some coaching.

I have a report based on a parameter query. I have it set to take the parameter value from a form that I use to preview and print reports.
I have to repeatedly print that report using a different value each time. I want to set it up to batch print, taking the values from a list in a table.

Thanks for your time
Easiest way if you're not familiar with VBA

Change the report datasource so that the parameter is table driven, link to the paramater table, create a group for the parameter and have the report do a page break on the parameter group.

The parameter table could have a yes/no field that you could use to toggle the parameter on and off.
Feb 20 '08 #2
Missionary
30 New Member
Easiest way if you're not familiar with VBA

Change the report datasource so that the parameter is table driven, link to the paramater table, create a group for the parameter and have the report do a page break on the parameter group.

The parameter table could have a yes/no field that you could use to toggle the parameter on and off.
That is basically how I had it before. But I ran into a problem with the headers and footers. For each report (or group) I have a report header that goes above the page header on the first page. How can I make the group header come above the page header?

Also, I want the page numbers in the page footer to restart with each group. I found how to do that on this site:
http://www.mvps.org/access/reports/rpt0013.htm
and I followed the directions, but it didn't work. Perhaps my settings on the controls were wrong. I'm not sure what he's talking about when he says "control name of the group" And what type of control should ctlGrpPages be? should it be unbound? etc.

So that's where I got held up and thought that batch printing might be easier. Any help would be apreciated.

I'm not afraid of VBA, I'm just brand new at it and need some coaching.

Thanks alot!
Feb 21 '08 #3
mshmyob
904 Recognized Expert Contributor
Hello Missionary,

Group headers CANNOT come above Page Headers.

That is basically how I had it before. But I ran into a problem with the headers and footers. For each report (or group) I have a report header that goes above the page header on the first page. How can I make the group header come above the page header?

Also, I want the page numbers in the page footer to restart with each group. I found how to do that on this site:
http://www.mvps.org/access/reports/rpt0013.htm
and I followed the directions, but it didn't work. Perhaps my settings on the controls were wrong. I'm not sure what he's talking about when he says "control name of the group" And what type of control should ctlGrpPages be? should it be unbound? etc.

So that's where I got held up and thought that batch printing might be easier. Any help would be apreciated.

I'm not afraid of VBA, I'm just brand new at it and need some coaching.

Thanks alot!
Feb 21 '08 #4
Missionary
30 New Member
Hello Missionary,
Group headers CANNOT come above Page Headers.
Thanks, mshmyob; that's what I figgured. What I could do is put the "Report Heading" in the Page Header, then just turn it on and off depending on the page number. Following is the Code I mentioned for the Page numbering that I got from
http://www.mvps.org/access/reports/rpt0013.htm

I added in some lines to make the ctlText visible or invisible.
Now, I could never get the page numbers to work in the first place, so this is deffinately a stab in the dark.
Where did I go wrong in the code?
Pls keep in mind that this is my first venture into VBA and I don't know the lingo.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. '************ Code Start *************
  4. ' This code was originally written by James H Brooks.
  5. ' It is not to be altered or distributed,
  6. ' except as part of an application.
  7. ' You are free to use it in any application,
  8. ' provided the copyright notice is left unchanged.
  9. '
  10. ' Code Courtesy of
  11. ' James H Brooks
  12. '
  13. Option Explicit
  14.  
  15. Dim GrpArrayPage(), GrpArrayPages()
  16. Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
  17. Dim GrpPage As Integer, GrpPages As Integer
  18.  
  19. Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
  20. Dim i As Integer
  21.   If Me.Pages = 0 Then
  22.     ReDim Preserve GrpArrayPage(Me.Page + 1)
  23.     ReDim Preserve GrpArrayPages(Me.Page + 1)
  24.     GrpNameCurrent = Me!ctlWard
  25.     If GrpNameCurrent = GrpNamePrevious Then
  26.         Me!ctlText.Visible = False     'Turn off the "Heading"
  27.         GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
  28.         GrpPages = GrpArrayPage(Me.Page)
  29.             For i = Me.Page - ((GrpPages) - 1) To Me.Page
  30.                 GrpArrayPages(i) = GrpPages
  31.             Next i
  32.     Else
  33.         Me!ctlText.Visible = True   'Turn on the "Heading"
  34.         GrpPage = 1
  35.         GrpArrayPage(Me.Page) = GrpPage
  36.         GrpArrayPages(Me.Page) = GrpPage
  37.     End If
  38.   Else
  39.     Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
  40.   End If
  41.   GrpNamePrevious = GrpNameCurrent
  42. End Sub
  43. '************ Code End *************
I have a textbox called ctlWard in the Group Header that shows the Group value.
I have an unbound textbox called ctlGrpPages that is supposed to show the page number In the page footer. Whenever I preview the Report, ctlGrpPages just shows up empty. Also, ctlText doesn't disapear.

Sorry this question is so long. I think I may be getting ahead of myself, but I'm hoping it will work.
Feb 21 '08 #5
jaxjagfan
254 Recognized Expert Contributor
That is basically how I had it before. But I ran into a problem with the headers and footers. For each report (or group) I have a report header that goes above the page header on the first page. How can I make the group header come above the page header?

Also, I want the page numbers in the page footer to restart with each group. I found how to do that on this site:
http://www.mvps.org/access/reports/rpt0013.htm
and I followed the directions, but it didn't work. Perhaps my settings on the controls were wrong. I'm not sure what he's talking about when he says "control name of the group" And what type of control should ctlGrpPages be? should it be unbound? etc.

So that's where I got held up and thought that batch printing might be easier. Any help would be apreciated.

I'm not afraid of VBA, I'm just brand new at it and need some coaching.

Thanks alot!
In your case I sometimes drop the report and page header/footer and use group header/footer. I even create a "dummy" column to group on in some cases to allow for a bit of creativity in the report layout.

With that being said heres some VBA. I have a table which lists all my reports by their Access name, Descriptive name, description - lstReports. I have a "Parameter" table - data in lstParam.

You can customize to loop thru and print each seperately.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdGenReport_Click()
  2.  
  3. If Me.lstParams.ItemsSelected.Count = 0 Then
  4. DoCmd.OpenReport Me.lstReports.Column(0), acViewPreview
  5. Else
  6. Call ParamList
  7. DoCmd.OpenReport Me.lstReports.Column(0), acViewPreview, , strFilter
  8. End If
  9. strFilter = ""
  10. Me.lstParams.Requery
  11.  
  12. End Sub
  13.  
Expand|Select|Wrap|Line Numbers
  1. Public Function ParamList()
  2.  
  3. Dim ctl As Control, varParam As Variant
  4. Set ctl = Me.lstParams
  5. For Each varParam In ctl.ItemsSelected
  6.     If strFilter = "" Then
  7.     strFilter = "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
  8.     Else: strFilter = strFilter & " Or " & "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
  9.     End If
  10. Next varParam
  11.  
  12. End Function
  13.  
Feb 21 '08 #6
NeoPa
32,563 Recognized Expert Moderator MVP
You say that you have a report which is driven by a control on your form.
How about some code on your form which loops through all the items you need reports for, and, for each iteration through the loop, sets the control to the current value then opens the report. When the loop is finished all your reports should have printed off.

NB. This will not work well for viewing the results in PrintPreview mode, as each subsequent call would replace the data from the previous one.
Feb 21 '08 #7
Missionary
30 New Member
That sounds good NeoPa, but I'm still struggling with the code.

Jaxjagfan, your post went a bit over my head. Could you explain in more basic terms. Where do I paste this code? What parts of the code do I need to change to my own table/field names, etc.


Thank you all for your help.
Feb 22 '08 #8
NeoPa
32,563 Recognized Expert Moderator MVP
That sounds good NeoPa, but I'm still struggling with the code.
...
That's fine Missionary.
Put together what you can and we can fill in the gaps. We don't (shouldn't) just provide solutions, as that doesn't help you to develop your skills or understanding.
Feb 22 '08 #9
Missionary
30 New Member
That's fine Missionary.
Put together what you can and we can fill in the gaps. We don't (shouldn't) just provide solutions, as that doesn't help you to develop your skills or understanding.
I didn't get to work on this very long as I'm going out of town this weekend, but here is what I've got so far:
I have a form with a comboBox called Wards that the query looks at to find the what records to show in the report.

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPrintAll_Click()
  2.   If Me.Wards.ItemsSelected.Count = 0 Then
  3.   'What is "ItemsSelected"?  It didn't recognise that
  4.     DoCmd.OpenReport rptRetentionReport, acViewNormal
  5.     'I don't know what this If statement is for.  Perhaps to print the first one?
  6.   Else
  7.     Call ParamList
  8.     DoCmd.OpenReport rptRetentionReport, acViewNormal, , strFilter
  9.     'This prints on condition
  10.   End If
  11.   strFilter = ""
  12.   'This is the condition.  I Don't understand what this says
  13.   Me.Wards.Requery
  14.   'I think this refreshes the form, but not sure
  15. End Sub
  16.  
  17. Public Function ParamList()
  18.   Dim ctl As Control, varParam As Variant
  19.   Set ctl = Me.Wards
  20.   For Each varParam In ctl.ItemsSelected
  21.   'again, it didn't like "ItemsSelected"
  22.     If strFilter = "" Then
  23.       strFilter = "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
  24.     Else
  25.       strFilter = strFilter & " Or " & "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
  26.     End If
  27.   Next varParam
  28. End Function
Feb 23 '08 #10

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

Similar topics

0
1297
by: Zentil | last post by:
While printing reports Spooling of print document size get increased into larger size ie the document size is 260kb but on spooling it increased to 268mb. but this is happening in some systems only. if anyone help on this it will be useful to me
2
2197
by: Ardie | last post by:
Hi, I'm currently working on a webapp that generates reports for the user and i was wondering if there was a way to do batch printing. I was playing around with the idea of sending the reports to a browser window and then starting the print job from there, but i need to know if i can insert a page break or something so that the printer will...
1
3229
by: Mitchell Vincent | last post by:
I've had this trouble in every language I've tried for Windows. Apparently the problem is with the underlying controls or something.. When I loop through and use a hidden web gadget to load and summarily print many HTML docs (say, over 5) I get them out of order, some don't print, and some print all unformatted. It's the strangest thing I've...
2
1317
by: Hexman | last post by:
Hello All, I'm now getting into the reporting phase of my application development. I need to print not only continuous page reports from a datasource (database, datagridview, listboxes, etc), but also some single page reports which the content is derived from calculated variables, constants, etc. I'm using VB.net Pro so CR seems like the...
1
1584
by: Parasyke | last post by:
Thanks for any help.. I currently have a database with about 100 products with picture links in an external folder. I have a form from which I can successfully display a product, its specifications, and print a sheet with the picture and the relative data. I'm trying to write some code to allow me to bring up the products and add them to a...
1
3251
by: Casey Skousen | last post by:
I want to be able to batch print all records in a header table that have not yet been printed. This should be simple, but due to the format of the report, I cannot just print all records (the details linked to each heder record all appear on one report rather than on seperate reports). I have a print flag in my header table to identify if a...
0
1619
by: jiafangsee | last post by:
Hi, I'm using Visual Studio 2005 and I have a web application where i generated some delivery order in crystal report then it's exported to pdf for viewing and printing. Now I need to develop method to export multiple pdf delivery order into a single pdf for batch printing. How should I export multiple DO into one single document? Any...
6
5998
by: bhughes2187 | last post by:
Ok people here have been an extremely great help. I have a problem once again.. It was working fine but now is broke again. I have a routine that loops through my reports and sends them to a printer or PDFCreator. Wierd thing is, my first report that has color on it, keeps coming out black and white.. Every other report that has color prints...
1
2476
by: kstevens | last post by:
I always have the same issue here and am wondering if anybody else does. I use adobe to print my reports to for ease of sharing with customers, and looking professional while doin it. The code i have sets the default printer to the "Adobe PDF" then commences printing. Since i set the name of the file on format, i have to actaully open the...
0
7467
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.