PC Review


Reply
Thread Tools Rate Thread

Print PDF Reports Filename & Specify A Path

 
 
Antney
Guest
Posts: n/a
 
      9th Jul 2008
Hi,

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. Can anyone
help? Thanks!

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


 
Reply With Quote
 
 
 
 
Albert D. Kallal
Guest
Posts: n/a
 
      9th Jul 2008
Assuming your are using Stephans pdf system, then:

strReport = "rptStudentDataSheet_0708"
With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport strReport, acViewNormal, ,"School = " &
rs("School")
reports(strReports).Visible = false
strDocName = "c:\MyoutPutdir\" & !SchoolName & ".pdf"
Call ConvertReportToPDF(strReport, , strDocName, False,
False)
DoCmd.Close acReport, strReportName
rs.MoveNext
Loop
End With


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)


 
Reply With Quote
 
Antney
Guest
Posts: n/a
 
      10th Jul 2008
Albert,

Thanks for the code, I appreciate it! As I'm trying to get it to work, I got
a 'Sub or Function not defined' and it's referring to 'Call
ConvertReportToPDF'. How do I define this?

Thanks!

"Albert D. Kallal" wrote:

> Assuming your are using Stephans pdf system, then:
>
> strReport = "rptStudentDataSheet_0708"
> With rs
> Do Until (.EOF Or .BOF) = True
> DoCmd.OpenReport strReport, acViewNormal, ,"School = " &
> rs("School")
> reports(strReports).Visible = false
> strDocName = "c:\MyoutPutdir\" & !SchoolName & ".pdf"
> Call ConvertReportToPDF(strReport, , strDocName, False,
> False)
> DoCmd.Close acReport, strReportName
> rs.MoveNext
> Loop
> End With
>
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> (E-Mail Removed)
>
>
>

 
Reply With Quote
 
Albert D. Kallal
Guest
Posts: n/a
 
      10th Jul 2008
"Antney" <(E-Mail Removed)> wrote in message
news:92229BD3-C174-4767-8141-(E-Mail Removed)...
> Albert,
>
> Thanks for the code, I appreciate it! As I'm trying to get it to work, I
> got
> a 'Sub or Function not defined' and it's referring to 'Call
> ConvertReportToPDF'. How do I define this?
>


The convertReportToPDF is a free pdf creator that you can find here:
http://www.lebans.com/reporttopdf.htm

The beauty of the above system is that it is free, and does not even require
you to install a pdf printer driver or anything (so, it is a VERY nice
solution).

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)


 
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
Re: Why do filename and path info not print in Word? Graham Mayor Microsoft Word Document Management 0 22nd Sep 2004 05:00 PM
Re: Why do filename and path info not print in Word? Jay Freedman Microsoft Word Document Management 0 22nd Sep 2004 04:59 PM
Why do filename and path info not print in Word? =?Utf-8?B?ZGVucnVz?= Microsoft Word Document Management 0 22nd Sep 2004 04:51 PM
Print The DB Path in Reports Bill Phillips Microsoft Access 1 3rd Apr 2004 12:50 AM
How to derive the path of a filename without the filename Shadowboxer Microsoft VB .NET 12 20th Sep 2003 05:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:11 PM.