Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Reports _ Export To .pdf - Split Pdf

Posted by: bakersburg9 Aug 14 2019, 12:24 PM

I did a search in UA, and found nothing on "pdf" - not much success on the 'net - so I'm exporting an Access report to pdf - but I want to split it at each section - anyone know how that can be done ? What I found says:

QUOTE
First, open the PDF file that you want to break into different parts....
Fine. Easy enough......... THEN, it says:
QUOTE
Click on the tools pane
*buzz* I'm done - WHAT 'Tools' pane ?

Posted by: theDBguy Aug 14 2019, 12:33 PM

Hi. What do you mean by "section?"

Posted by: bakersburg9 Aug 14 2019, 12:44 PM

Section - like this

Yeah, I found one site where it looked like a great site, but you had to "Start Free Trial" - yeah, and give them my credit card #, etc.

 

Posted by: theDBguy Aug 14 2019, 01:00 PM

Sounds like section = group, correct? If so, one possible solution is to loop through the groups and filter the report to output each one as a PDF.

Posted by: bakersburg9 Aug 14 2019, 01:02 PM

QUOTE
possible solution is to loop through the groups
loop through the groups ?

Posted by: theDBguy Aug 14 2019, 01:05 PM

You were using Grouping in your report, correct? If so, yes, that's what I was saying. For example, let's say you're grouping by [DeptID], then you should be able to create a query to get a unique list all DeptID. You then loop through this list and output a filtered report based on the value of DeptID in the loop.

Posted by: bakersburg9 Aug 14 2019, 01:30 PM

I'm sorry, I still don't understand what you mean by 'loop through' - a sample db with just one report is attached - I'm grouping by the Project Director in this case, or fieldname: PDatInception





 CostNoBillingUA207p.zip ( 88.63K ): 1
 

Posted by: tina t Aug 14 2019, 01:39 PM

QUOTE
What I found says:
QUOTE
First, open the PDF file that you want to break into different parts....
Fine. Easy enough......... THEN, it says:
QUOTE
Click on the tools pane
*buzz* I'm done - WHAT 'Tools' pane ?

fyi, the above, if i'm not mistaken, is talking about splitting a PDF file that already exists - which is a different subject than printing "sections" of a report to separate PDF files. and not something you can do from within Access, AFAIK, unless you're using code that manipulates external software to accomplish the task.

hth
tina

Posted by: bakersburg9 Aug 14 2019, 01:43 PM

QUOTE
talking about splitting a PDF file that already exists

Tina,
That IS what I'm talking about... although I would like to do some "splitting" at an intermediate step grin.gif

Posted by: theDBguy Aug 14 2019, 01:54 PM

Hi Steve. Not sure if this is what you mean anymore but check out the attached file. Go to the Immediate Window and enter the following:

CODE
?Report2PDF



 CostNoBillingUA.zip ( 84.52K ): 5
 

Posted by: bakersburg9 Aug 14 2019, 03:32 PM

DbGuy,
In the words of Todd Chrisley (Chrisley Knows Best) - ARE YOU KIDDING ME RIGHT NOW??? (Although I mean it in a good way, unlike Todd's intended meaning usually...

That was absolutely AWESOME!!!!

Thank you, thank you, THANK YOU!!!! OMG, this is so great !!! cool.gif

I figured we'd go back and forth, and maybe something would be accomplished.... wow, wow, wow !!
- how do you KNOW this stuff ? uarulez2.gif

Steve

 

Posted by: theDBguy Aug 14 2019, 03:34 PM

Hi Steve. Glad we could assist. Continued success with your project.

Posted by: bakersburg9 Aug 14 2019, 04:03 PM

DB,

I haven't gone over it with a fine-toothed comb yet... more like: "once I was blind, and now I see" - like I won the Lottery, and I'm like: "Are you SURE mine is the winning ticket ?

But was that Project manager file with the names CREATED, or did you have to set it up ? Just wondering - even if I do, it will be super easy

One thing I did at my current job is combine reports into one PDF - could that be done as well if I have to, do you think ?

Thanks again !!!! cool.gif

Steve

Posted by: theDBguy Aug 14 2019, 04:10 PM

Hi Steve. The file names for the PDF files are coming from the report group's values. To combine multiple PDF files into one, you could ask Tina. She has a thread here where she was able to get some help from Albert for doing something like that.

Posted by: bakersburg9 Aug 14 2019, 04:17 PM

About Tina - this is weird - she VERY recently chimed in on one of my posts - now her profile pic is the greyed out generic thing, and I couldn't PM her
steve

Posted by: theDBguy Aug 14 2019, 04:32 PM

Hi. Don't quote me but maybe grayed out means she's offline.

Posted by: tina t Aug 14 2019, 07:12 PM

hi Steve, re DBguy's remark, see Albert Kallal's solution in https://www.UtterAccess.com/forum/index.php?s=&showtopic=2054460&view=findpost&p=2724346. it has one drawback: it doesn't work with pdf files created in Adobe Acrobat 6.0 and newer. pdf files from other sources i've had no problem with, so far - including Access reports printed to pdf using DoCmd.PrintOut with the acFormatPDF argument (in A2016, i don't know about older versions).

in fact, i wrote a small table+form+code in A2016 to handle merging multiple files at one time. it's nothing special, anyone could do it, but since i already did the work you're welcome to a copy if you want it.

hth
tina

Posted by: bakersburg9 Aug 15 2019, 11:00 AM

DBGuy,
Help !

I tried writing a new function, and it's erring - says the report name does not exist, but it does - I think this may be where Access is being 'quirky' - truth be told, some of this code I did find/replace, and it left a period (.) when I was done - I thought just deleting the period would do it, but maybe not


CODE
Public Function ReportToPDFByDivision1() As Long

'********************************************** Make sure to have correct field "PDatIncception," "Office," whatever

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
                        
Set rs = db.OpenRecordset("qCostZeroNoInvByOrigOfficeDiv1")

With rs
    Do While Not .EOF
    
        DoCmd.OpenReport "    rCostZeroNoInvByOrigOfficeDiv1", acViewPreview, , "OrigOffice='" & !OrigOffice & "'", acHidden
        DoCmd.OutputTo acOutputReport, "    rCostZeroNoInvByOrigOfficeDiv1", acFormatPDF, CurrentProject.Path & "\" & Replace(!OrigOffice, ";", "_") & ".pdf"
                                      
        DoCmd.Close acReport, "    rCostZeroNoInvByOrigOfficeDiv1"
        .MoveNext
     Loop
    .Close
End With

Set rs = Nothing
Set db = Nothing

  ReportToPDFByDivision1 = Err.Number

End Function


Edit: Can I just set up "new" dimensions with the same names in a different function / module ?

like

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("Query1")

can I use these again?


 

Posted by: theDBguy Aug 15 2019, 11:16 AM

Hi Steve. It looks like you are trying to open a report with a bunch of spaces in front of its name, which cannot exist in real life.

Posted by: bakersburg9 Aug 15 2019, 11:27 AM

DBguy from sunny Sandy Eggo - Oh, Gawd, HOW did I not notice that ? Believe me, I didn't just make a panicky post on UA - I was focusing on the spelling - thanks for catching the obvious error - I'M the quirky one . . .

Posted by: theDBguy Aug 15 2019, 11:35 AM

You probably just haven't had your coffee yet. Take a break!