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
22 8929
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.
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!
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!
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. - Option Compare Database
-
-
'************ Code Start *************
-
' This code was originally written by James H Brooks.
-
' It is not to be altered or distributed,
-
' except as part of an application.
-
' You are free to use it in any application,
-
' provided the copyright notice is left unchanged.
-
'
-
' Code Courtesy of
-
' James H Brooks
-
'
-
Option Explicit
-
-
Dim GrpArrayPage(), GrpArrayPages()
-
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
-
Dim GrpPage As Integer, GrpPages As Integer
-
-
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
-
Dim i As Integer
-
If Me.Pages = 0 Then
-
ReDim Preserve GrpArrayPage(Me.Page + 1)
-
ReDim Preserve GrpArrayPages(Me.Page + 1)
-
GrpNameCurrent = Me!ctlWard
-
If GrpNameCurrent = GrpNamePrevious Then
-
Me!ctlText.Visible = False 'Turn off the "Heading"
-
GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
-
GrpPages = GrpArrayPage(Me.Page)
-
For i = Me.Page - ((GrpPages) - 1) To Me.Page
-
GrpArrayPages(i) = GrpPages
-
Next i
-
Else
-
Me!ctlText.Visible = True 'Turn on the "Heading"
-
GrpPage = 1
-
GrpArrayPage(Me.Page) = GrpPage
-
GrpArrayPages(Me.Page) = GrpPage
-
End If
-
Else
-
Me!ctlGrpPages = "Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)
-
End If
-
GrpNamePrevious = GrpNameCurrent
-
End Sub
-
'************ 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.
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. -
Private Sub cmdGenReport_Click()
-
-
If Me.lstParams.ItemsSelected.Count = 0 Then
-
DoCmd.OpenReport Me.lstReports.Column(0), acViewPreview
-
Else
-
Call ParamList
-
DoCmd.OpenReport Me.lstReports.Column(0), acViewPreview, , strFilter
-
End If
-
strFilter = ""
-
Me.lstParams.Requery
-
-
End Sub
-
-
Public Function ParamList()
-
-
Dim ctl As Control, varParam As Variant
-
Set ctl = Me.lstParams
-
For Each varParam In ctl.ItemsSelected
-
If strFilter = "" Then
-
strFilter = "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
-
Else: strFilter = strFilter & " Or " & "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
-
End If
-
Next varParam
-
-
End Function
-
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.
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.
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.
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: - Private Sub cmdPrintAll_Click()
-
If Me.Wards.ItemsSelected.Count = 0 Then
-
'What is "ItemsSelected"? It didn't recognise that
-
DoCmd.OpenReport rptRetentionReport, acViewNormal
-
'I don't know what this If statement is for. Perhaps to print the first one?
-
Else
-
Call ParamList
-
DoCmd.OpenReport rptRetentionReport, acViewNormal, , strFilter
-
'This prints on condition
-
End If
-
strFilter = ""
-
'This is the condition. I Don't understand what this says
-
Me.Wards.Requery
-
'I think this refreshes the form, but not sure
-
End Sub
-
-
Public Function ParamList()
-
Dim ctl As Control, varParam As Variant
-
Set ctl = Me.Wards
-
For Each varParam In ctl.ItemsSelected
-
'again, it didn't like "ItemsSelected"
-
If strFilter = "" Then
-
strFilter = "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
-
Else
-
strFilter = strFilter & " Or " & "ParamField = " & "'" & ctl.ItemData(varParam) & "'"
-
End If
-
Next varParam
-
End Function
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |