PC Review


Reply
Thread Tools Rate Thread

Code to print to PDF & cycle until EOF

 
 
Antney
Guest
Posts: n/a
 
      9th Jul 2008
Hi, I work for a school district and I have reports, for each school, that I
want to print to PDF. The thing is is that I want the print command button to
print the reports, in PDF format, separating each school in its' own PDF,
create a file name for that school and then send the PDF to a designated
folder. I would like the program to cycle through each school until the end.
If I haven't explained it thoroughly enough or clearly enough, please let me
know.

Can anyone help me out with this? It would be greatly appreciated!
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      9th Jul 2008
have a look here:
http://www.lebans.com/reporttopdf.htm

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

"Antney" <(E-Mail Removed)> wrote in message
news:B726842C-6273-43BD-8E90-(E-Mail Removed)...
> Hi, I work for a school district and I have reports, for each school, that
> I
> want to print to PDF. The thing is is that I want the print command button
> to
> print the reports, in PDF format, separating each school in its' own PDF,
> create a file name for that school and then send the PDF to a designated
> folder. I would like the program to cycle through each school until the
> end.
> If I haven't explained it thoroughly enough or clearly enough, please let
> me
> know.
>
> Can anyone help me out with this? It would be greatly appreciated!


 
Reply With Quote
 
Antney
Guest
Posts: n/a
 
      9th Jul 2008
Hi and thank you, it was helpful. I have another question;

I've figured out how to print Access reports to PDF but now that I've
printed them, I want, in VBA code, to figure out how I can get the VBA code
to automatically print each reports name, instead of me having to type it in
once the 'File Name' dialog box pops up and then send it automatically to a
specifed folder instead of me again, having to specify a path.

BTW, in my 'qrySchools', which links the school id with the
'rptStudentDataSheet_0708' school id, I do have the school name. That's the
file name I want to use for each respective report.

Here is my code:

Option Compare Database
Option Explicit

Private Sub cmdPrintReports_Click()
On Error GoTo Err_cmdPrintReports_Click

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

Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)

With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport "rptStudentDataSheet_0708",
View:=acViewNormal, _
WhereCondition:="School = " & rs("School")
rs.MoveNext
Loop
End With

Exit_cmdPrintReports_Click:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub

Err_cmdPrintReports_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
Resume Exit_cmdPrintReports_Click
End Sub




"Alex Dybenko" wrote:

> have a look here:
> http://www.lebans.com/reporttopdf.htm
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
> "Antney" <(E-Mail Removed)> wrote in message
> news:B726842C-6273-43BD-8E90-(E-Mail Removed)...
> > Hi, I work for a school district and I have reports, for each school, that
> > I
> > want to print to PDF. The thing is is that I want the print command button
> > to
> > print the reports, in PDF format, separating each school in its' own PDF,
> > create a file name for that school and then send the PDF to a designated
> > folder. I would like the program to cycle through each school until the
> > end.
> > If I haven't explained it thoroughly enough or clearly enough, please let
> > me
> > know.
> >
> > Can anyone help me out with this? It would be greatly appreciated!

>
>

 
Reply With Quote
 
Alex Dybenko
Guest
Posts: n/a
 
      10th Jul 2008
Hi,
if you are using ConvertReportToPDF routine from provided link - then you
can specify exact file name pdf will be saved, check sample code there

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

"Antney" <(E-Mail Removed)> wrote in message
news:06163518-A329-4F21-92C2-(E-Mail Removed)...
> Hi and thank you, it was helpful. I have another question;
>
> I've figured out how to print Access reports to PDF but now that I've
> printed them, I want, in VBA code, to figure out how I can get the VBA
> code
> to automatically print each reports name, instead of me having to type it
> in
> once the 'File Name' dialog box pops up and then send it automatically to
> a
> specifed folder instead of me again, having to specify a path.
>
> BTW, in my 'qrySchools', which links the school id with the
> 'rptStudentDataSheet_0708' school id, I do have the school name. That's
> the
> file name I want to use for each respective report.
>
> Here is my code:
>
> Option Compare Database
> Option Explicit
>
> Private Sub cmdPrintReports_Click()
> On Error GoTo Err_cmdPrintReports_Click
>
> Dim db As DAO.Database
> Dim rs As DAO.Recordset
>
> Set db = CurrentDb()
> Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
>
> With rs
> Do Until (.EOF Or .BOF) = True
> DoCmd.OpenReport "rptStudentDataSheet_0708",
> View:=acViewNormal, _
> WhereCondition:="School = " & rs("School")
> rs.MoveNext
> Loop
> End With
>
> Exit_cmdPrintReports_Click:
> 'Cleanup
> On Error Resume Next
> rs.Close: Set rs = Nothing
> db.Close: Set db = Nothing
> Exit Sub
>
> Err_cmdPrintReports_Click:
> MsgBox "Error " & Err.Number & ": " & Err.Description, _
> vbCritical, "Error in Test subroutine..."
> Resume Exit_cmdPrintReports_Click
> End Sub
>
>
>
>
> "Alex Dybenko" wrote:
>
>> have a look here:
>> http://www.lebans.com/reporttopdf.htm
>>
>> --
>> Best regards,
>> ___________
>> Alex Dybenko (MVP)
>> http://accessblog.net
>> http://www.PointLtd.com
>>
>> "Antney" <(E-Mail Removed)> wrote in message
>> news:B726842C-6273-43BD-8E90-(E-Mail Removed)...
>> > Hi, I work for a school district and I have reports, for each school,
>> > that
>> > I
>> > want to print to PDF. The thing is is that I want the print command
>> > button
>> > to
>> > print the reports, in PDF format, separating each school in its' own
>> > PDF,
>> > create a file name for that school and then send the PDF to a
>> > designated
>> > folder. I would like the program to cycle through each school until the
>> > end.
>> > If I haven't explained it thoroughly enough or clearly enough, please
>> > let
>> > me
>> > know.
>> >
>> > Can anyone help me out with this? It would be greatly appreciated!

>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cycle through tables in another DB from code =?Utf-8?B?Y2hlcm1hbg==?= Microsoft Access VBA Modules 3 26th Apr 2007 04:49 AM
vba code to cycle through each column in a sheet GJones Microsoft Excel Programming 0 16th Sep 2004 08:54 PM
Getting VBA code to cycle thru all records Lee-Anne Microsoft Access VBA Modules 3 27th Sep 2003 08:16 PM
Re: Getting VBA code to cycle thru all records Tim Ferguson Microsoft Access VBA Modules 2 26th Sep 2003 07:48 PM
?Code to cycle through forms controls Lisa B. Microsoft Access VBA Modules 6 8th Aug 2003 12:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:08 AM.