473,503 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In Access, How to Convert Multiple Reports to 1 PDF file?

18 New Member
I want to add a control button to convert all reports for 1 selected record to print in page order as 1 pdf file. There is a control button to print 1 full report per selected record but some users will want to pdf the report to email to clients. What would the VBA coding be for the On Click Event Procedure for the PDF Report button? Or would a macro be better? I am a beginner with VBA & macros so elementary explanations/coding would be helpful....Thank you!
Sep 10 '10 #1
25 18794
liimra
119 New Member
You can use either but I would go for VBA.

If you want to use macro, use the "OutputTo" action. Choose report as Object Type and select the report name.

If you want to use VB
Expand|Select|Wrap|Line Numbers
  1.  DoCmd.OutputTo acReport, "ReportName", acFormatPDF, , True 
Note: "True" will open the Pdf file after completing.

Hope this is what you need,

Regards,
Ali
Sep 10 '10 #2
Otter7
18 New Member
Yes, but do I need to list all the report names? There are 23 individual reports per 1 recored to be a single pdf file in page order...so the user can save the pdf ie as 'One Montgomery Audit'....
Sep 10 '10 #3
Otter7
18 New Member
Wooh! That worked except the pdf file is showing all the records and I need just 1 record selected from a drop down list. The user cannot enter data, preview or print or pdf unless an audit is selected...This is the code I have but wiill add all the rpt nams...

Private Sub btnPDF_Click()
If Audit_Dte_ID = 0 Then
MsgBox "No audidt has been selected"
Exit Sub
End If
DoCmd.OutputTo acReport, "rpt1aAuditorinfo", acFormatPDF, , True

End Sub
-----

How do I code it so pdf is only the selected audit records?
Sep 10 '10 #4
liimra
119 New Member
I have one solution and of course there are others.
When the user chooses the record he/she wants, we search for that record (using the combobox After Update event).

The "Drop Down List" After Update event will be:

Expand|Select|Wrap|Line Numbers
  1.  DoCmd.SearchForRecord , "", , "[Audit_Dte_ID]=" & ComboName.Column(0)
Where Audit_Dte_ID is the first column in the record source of the combo box.

Now, we have the record we want so we just add the code you stated to the Export button.

Expand|Select|Wrap|Line Numbers
  1. If ComboName Is Null Then
  2. MsgBox "No audit has been selected", vbOKOnly, "No Selection"
  3. ElseIf Combo Is Not Null Then
  4. DoCmd.OutputTo acReport, "rpt1aAuditorinfo", acFormatPDF, , True
  5. End If
  6.  
Hope this helps,

Regards,
Ali
Sep 10 '10 #5
Otter7
18 New Member
Ok...I'll give it a try and respond later this evening, California time...off work right now...Thanks and I will respond back...
Sep 10 '10 #6
Otter7
18 New Member
This is the code I entered but it does not work, comes up as error End If:

Private Sub btnPDF_Click()
If Audit_Dte_ID = 0 Then
MsgBox "No audit has been selected"
ElseIf Me.Combo66 Is Not Null Then
End If
DoCmd.OutputTo acReport, "rpt1aAuditorinfo", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True
DoCmd.OutputTo acReport, "rpt1ProjectBldgInfo", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True
DoCmd.OutputTo acReport, "rpt2Construction", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True
DoCmd.OutputTo acReport, "rpt3Bldgoccupancy", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True
DoCmd.OutputTo acReport, "rpt4CoolingPlant", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True
DoCmd.OutputTo acReport, "rpt5HVACSystem", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True
DoCmd.OutputTo acReport, "rpt6ComfortHeating", acFormatPDF, , "Audit_dte_id=" & Audit_Dte_ID, , True

Continues with all the report names and last line is End Sub..I'm still missing the loop somewhere...
Sep 11 '10 #7
liimra
119 New Member
There are two problems with your code, The "If Statement" and the fact that you can't assign criteria to the OutputTo Function.

In order to overcome the problem you are having and output the selected record only, you open the report first in preview mode then you Output it to PDF. Once this is done, you close back the report preview. Suppose the user cancels the out operation, then he/she will get "cancel" error --> that is why you Resume Next on Error.

So the code will be:

Expand|Select|Wrap|Line Numbers
  1. If (Eval("[Forms]![FormName]![Audit_Dte_ID] Is Null")) Then
  2.  MsgBox "No audit has been selected"
  3.  ElseIf (Eval("[Forms]![FormName]![Audit_Dte_ID] Is Not Null")) Then
  4.  On Error Resume Next
  5. DoCmd.OpenReport "FirstReportName", acViewPreview, , "[Audit_Dte_ID]= " & Forms!FormName!Audit_Dte_ID
  6. DoCmd.OutputTo acOutputReport, "FirstReportName", acFormatPDF, , True
  7. DoCmd.Close
  8. DoCmd.OpenReport "SecondReportName", acViewPreview, , "[Audit_Dte_ID]= " & Forms!FormName!Audit_Dte_ID
  9. DoCmd.OutputTo acOutputReport, "SecondReportName", acFormatPDF, , True
  10. DoCmd.Close
  11. End If
Change names where applicable & add the number of reports you want, and you are done.

Regards,
Ali
Sep 11 '10 #8
Otter7
18 New Member
For the "FormName" I enter the name of the form but for [Forms] I do not enter the form name, correct?
Sep 11 '10 #9
liimra
119 New Member
Correct

Regards,
Ali
Sep 11 '10 #10
Otter7
18 New Member
I'm not following exactly as I enter the form name MainForm which is a switchboard with control buttons to select certain forms to enter data after the user selects an audit from the drop down: there are 37 forms...the Print button works which loads all the reports into a single file to be printed...I thought I could do this with saving as a pdf. Perhaps I could email you my Db through my personal email to your personal email?
Sep 11 '10 #11
liimra
119 New Member
I will create an example of what I am talking about and attach it once finished.

Regards,
Ali
Sep 12 '10 #12
liimra
119 New Member
Kindly note what I stated before in the attached database.

Regards,
Ali
Attached Files
File Type: zip PDFReport.zip (34.8 KB, 693 views)
Sep 12 '10 #13
Otter7
18 New Member
Had a grid power failure...I will send another response tomorrow after reviewing your pdf sample...thank you for your assistance!.
Sep 13 '10 #14
Otter7
18 New Member
The sample you submitted worked except, the reports are saving as individula pdf files...I'm trying to save all the reports for the selected record into 1 pdf file....is there an operator that stops the single pdf page from saving and holds it until the next cmd to save a page is added, etc. then the entire report is in 1 saved pdf file?
Sep 13 '10 #15
liimra
119 New Member
Glad we achieved something. For saving all into one file,
How about creating one main unbound report with all the reports inside it as sub reports? This will work.

Regards,
Ali
Sep 13 '10 #16
Otter7
18 New Member
I will give it a try and reply back tomorrow....Thanks for checking in and assisting!
Sep 13 '10 #17
Otter7
18 New Member
Unsuccessful, could not get the unbound report/subreports to work either...VBA must have some type of operator? to cause ongoing pagnation when saving multiple reports to the same pdf....I'll keep trying different variations of all that you submitted...any other coding you can think of? Thank you!
Sep 14 '10 #18
Otter7
18 New Member
How do I create an unbound main report with all the existing reports being the subreports plus when clicking on this report opens only 1 record from the If combobox = 0; MsgBox "No Audit has been selected"?

I am still trying to save 1 selected record after selecting through a combox listing, the 23 reports into 1 pdf file...
Sep 18 '10 #19
liimra
119 New Member
Create one main report (make it your 1/23 report) and put all the other 22 reports inside it (so they become subreports). You have to note however, that unless you put each report in seperate section, you will get alittle mess with all reports above each others. To overcome this, create groups and set the expression value to =true for each one. For the msgbox, you can use the same as stated before "Is Null" or ="" although they are not exactly the same.

Last but not least make sure you link all the subreports to the main report through "ID".

Please report here if you have any problems and I will search tonight when I get back for a ready example over the net or create it.

Regards,
Ali
Sep 18 '10 #20
liimra
119 New Member
Did you get it working?

Regards,
Ali
Sep 18 '10 #21
Otter7
18 New Member
Thank you for responding...I was out of town on the weekend. I will follow your instructions today and respond wtih the results this afternoon.
Sep 20 '10 #22
Otter7
18 New Member
Still need your assitance...I seem to be missing something as the subreports are not showing as separate sections and not sure how to do a grouping with subreports...would you mind posting a sample..or please post as a private message...Thank you!
Sep 22 '10 #23
liimra
119 New Member
Please find in the attached database the example I am talking about. Unfortunately the maximum number of groups is 10 so The main report has 10 reports. Of course you can add two reports to each group and then two reports in the form itself so you can reach 22 reports. Without any doubt there must be a way to add 23 reports but I will be traveling in the next two days so I won't be able to assist further. Anyways, here is how it works:

First you create report based on the table you are getting the records from, then you empty it (you just use it as source so you can create Master-Child Link for the subreports in order to filter). Next, you create groups (Group&Sort --> add group --> expression --> =true). Now you add report to each group (or two) and you are done.

Regards,
Ali
Attached Files
File Type: zip PDFReport2.zip (206.9 KB, 636 views)
Sep 23 '10 #24
Otter7
18 New Member
Thank you for the sample...it helps to use a visual...I should be good from here...hope your travel is relaxing!
Sep 23 '10 #25
Otter7
18 New Member
Ali, I am still working on this and need assistance. Here is what I am trying to create as you stated - 1 report with groups with subreports totaling 23 reports with 1 record selection and forcing a page break each report:

main report
Group - subrpt 1; subrpt2
Group - subrpt 3, subrpt4
Group - subrpt 4; subrpt 5
etc. to last has 4 subrpts

This is advanced for me...step by step would be helpful, if you have some time....Thank you!
Sep 29 '10 #26

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

Similar topics

2
4538
by: Sigurd Bruteig | last post by:
Hi all! I have a problem printing multiple reports. The code i use is: Dim stDocName As String stDocName = "rptInvoice" DoCmd.OpenReport stDocName, acNormal, , " = date()" The problem is that...
3
3836
by: MHenry | last post by:
Hi, I have 30 separate Access reports to print to pdf files. Presently, I print these reports to Acrobat pdf files one report at a time. I am looking for some help, or a program or add-in...
0
1170
by: mr_doles | last post by:
I have finally got the hang of this ReportViewer control. The one question that I have is dealing with multiple reports. If I have, lets say, 10 rdlc reports should I have 10 WinForms to put them...
0
1476
by: genc ymeri | last post by:
Hi over there, Does the .Net20 framework provide library classes/drivers to convert multiple single tiff files into a single multi-pages file or should I use third party tools ? Genc.
0
1070
by: KimJee | last post by:
Dear Sir, I am a Ms access 2003 vb programmer. I want to konw how to convert a Ms Access 2003 graphic reports in to a HTML file. Shall be ever gratefull for the assistance. Kim Jee.
2
6668
by: Thall | last post by:
Hey Gurus - I've seen a few solutions to this problem, but none of which I can do without a little help. Here's the situation The following code loops thru a sales report, using the sales rep ID...
3
1585
by: Ed | last post by:
Hi, dear all, Now there is a issue to convert C++ into CLI/C++. But there is a issue block me. Say Class MN is multiple derived from class MM and NN. But the CLI only allow single class...
0
1164
by: crazycat | last post by:
hello im face a problem with link multiple excel file with one access database for more information : 1- i have 27 excel file to employee that contain account number 2- this 27 excel file...
0
2066
by: mgarg005SSRS | last post by:
My requirement is to create multiple reports (.rdlc) and show them using single report viewer control. A: User selects a report from drop down list. B: Depending on report name a report has to be...
0
7205
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
7093
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
7348
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...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5592
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,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
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...

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.