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!
25 18794 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 - DoCmd.OutputTo acReport, "ReportName", acFormatPDF, , True
Note: "True" will open the Pdf file after completing.
Hope this is what you need,
Regards,
Ali
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'....
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?
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: - 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. - If ComboName Is Null Then
-
MsgBox "No audit has been selected", vbOKOnly, "No Selection"
-
ElseIf Combo Is Not Null Then
-
DoCmd.OutputTo acReport, "rpt1aAuditorinfo", acFormatPDF, , True
-
End If
-
Hope this helps,
Regards,
Ali
Ok...I'll give it a try and respond later this evening, California time...off work right now...Thanks and I will respond back...
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...
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: -
If (Eval("[Forms]![FormName]![Audit_Dte_ID] Is Null")) Then
-
MsgBox "No audit has been selected"
-
ElseIf (Eval("[Forms]![FormName]![Audit_Dte_ID] Is Not Null")) Then
-
On Error Resume Next
-
DoCmd.OpenReport "FirstReportName", acViewPreview, , "[Audit_Dte_ID]= " & Forms!FormName!Audit_Dte_ID
-
DoCmd.OutputTo acOutputReport, "FirstReportName", acFormatPDF, , True
-
DoCmd.Close
-
DoCmd.OpenReport "SecondReportName", acViewPreview, , "[Audit_Dte_ID]= " & Forms!FormName!Audit_Dte_ID
-
DoCmd.OutputTo acOutputReport, "SecondReportName", acFormatPDF, , True
-
DoCmd.Close
-
End If
Change names where applicable & add the number of reports you want, and you are done.
Regards,
Ali
For the "FormName" I enter the name of the form but for [Forms] I do not enter the form name, correct?
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?
I will create an example of what I am talking about and attach it once finished.
Regards,
Ali
Kindly note what I stated before in the attached database.
Regards,
Ali
Had a grid power failure...I will send another response tomorrow after reviewing your pdf sample...thank you for your assistance!.
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?
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
I will give it a try and reply back tomorrow....Thanks for checking in and assisting!
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!
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...
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
Did you get it working?
Regards,
Ali
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.
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!
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
Thank you for the sample...it helps to use a visual...I should be good from here...hope your travel is relaxing!
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!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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.
|
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.
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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: 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...
|
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,...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |