Exporting Report from Access into PDF

E

Erick C

Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!

Here is the code that I am working with right now:

Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"

End Sub
 
G

Gina Whipp

Erick,

Try...

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![YourControl]

'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next


'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!

Here is the code that I am working with right now:

Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"

End Sub
 
E

Erick C

Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.

Private Sub CreatePDF_Click()

Dim intCounter As Integer
Dim cboCode As ComboBox


Set cboCode = Me![Customers_To_Email]

'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next

End Sub


Erick,

Try...

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![YourControl]

'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
  DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
  DoEvents
  DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
  DoCmd.Close acReport, "YourReport"
Next

'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
  DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
  DoEvents
  DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
  DoCmd.Close acReport, "YourReport"
Next

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Hi everybody.
I am hoping someone may be able to help me out.  I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually.  I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer.  I tried to do a bit of modification to this code and add in
the OutputTo command with no luck.  Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before?  Can it be
done?  Can someone help me out or point me in the right direction?
Thanks!

Here is the code that I am working with right now:

Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
      MsgBox "No folder was selected.", vbOK, "No Selection"
      Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
      rstMgr.MoveFirst
      Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
           strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
                  "BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
            strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
                "BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
            Set qdf = dbs.QueryDefs(strTemp)
            qdf.Name = "q_" & strMgr
            strTemp = qdf.Name
            qdf.SQL = strSQL
            qdf.Close
            Set qdf = Nothing
          strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
          strPathFile = strPath & "\" & strFile
            DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
    acFormatPDF, strTemp, strPathFile
          rstMgr.MoveNext
     Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"

End Sub
 
G

Gina Whipp

Erick,

Before I adjust your code... I thought you wanted to use Stephen Leban's
ReportToPDF?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.

Private Sub CreatePDF_Click()

Dim intCounter As Integer
Dim cboCode As ComboBox


Set cboCode = Me![Customers_To_Email]

'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next

End Sub


Erick,

Try...

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![YourControl]

'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next

'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!

Here is the code that I am working with right now:

Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"

End Sub
 
E

Erick C

Gina -

I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.


Erick,

Before I adjust your code...  I thought you wanted to use Stephen Leban's
ReportToPDF?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems.  I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.

Private Sub CreatePDF_Click()

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![Customers_To_Email]

'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
  DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
  DoEvents
  DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
  DoCmd.Close acReport, "YourReport"
Next

End Sub

Erick,

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, , "[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!
Here is the code that I am working with right now:
Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"
End Sub- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

I'm here to help... so if step one is getting the ReportToPDF to work first
then lets do that... What problems are you having getting that code to
work? ANd where are you with it? Have you copied it into a module? Have
you put the .DLL's in place? You get the idea...

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina -

I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.


Erick,

Before I adjust your code... I thought you wanted to use Stephen Leban's
ReportToPDF?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.

Private Sub CreatePDF_Click()

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![Customers_To_Email]

'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next

End Sub

Erick,

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!
Here is the code that I am working with right now:
Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"
End Sub- Hide quoted text -

- Show quoted text -
 
E

Erick C

Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:

Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.

' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean

' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only

' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.


Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.



Erick,

I'm here to help... so if step one is getting the ReportToPDF to work first
then lets do that...  What problems are you having getting that code to
work?  ANd where are you with it?  Have you copied it into a module?  Have
you put the .DLL's in place?  You get the idea...

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -

I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF.  I do not have any preference as to where the code
comes from as long as it works correctly.  If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding.  I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway.  I just came here
first, that's all.

Before I adjust your code... I thought you wanted to use Stephen Leban's
ReportToPDF?
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![Customers_To_Email]
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
Erick,
Try...
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!
Here is the code that I am working with right now:
Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"
End Sub- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

Step 1 copy the module into your database and then type here the name of
your report. Also make sure you have a default printer assigned to windows.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:

Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.

' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean

' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only

' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.


Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.



Erick,

I'm here to help... so if step one is getting the ReportToPDF to work
first
then lets do that... What problems are you having getting that code to
work? ANd where are you with it? Have you copied it into a module? Have
you put the .DLL's in place? You get the idea...

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -

I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.

Before I adjust your code... I thought you wanted to use Stephen Leban's
ReportToPDF?
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![Customers_To_Email]
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
Erick,
Try...
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") &
".rtf"
DoCmd.Close acReport, "YourReport"
Next
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") &
".rtf"
DoCmd.Close acReport, "YourReport"
Next
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to pick a location to save the files and then create a PDF based
on a report that I have saved in Access for each customer
individually. I have been looking around online for a while and I
have been trying a few different things with not much success.
I had some code from Ken Snell that worked great for looping through
customer numbers and exporting an excel file for each individual
customer. I tried to do a bit of modification to this code and add in
the OutputTo command with no luck. Since the code uses a "dummy"
query to grab the information that is changing with each customer, I
do not know if I can have the properties of the report change every
time this source data changes.
I am trying to work with Stephen Leban's A2000ReportToPDF database
right now, but it is far more advanced than my puny range of code
knowledge will allow me to comprehend.
Is there anyone who has created something like this before? Can it be
done? Can someone help me out or point me in the right direction?
Thanks!
Here is the code that I am working with right now:
Dim qdf As DAO.QueryDef
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset, rstMgr1 As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
strBrowseMsg = "Select the folder where the files will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
Const strQName As String = "zExportQuery"
Set dbs = CurrentDb
' Create temporary query that will be used for exporting data;
' we give it a dummy SQL statement initially (this name will
' be changed by the code to conform to each manager's identification)
strTemp = dbs.TableDefs(0).Name
strSQL = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set qdf = dbs.CreateQueryDef(strQName, strSQL)
qdf.Close
strTemp = strQName
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
' Get list of ManagerID values -- note: replace my generic table and
Field names
' with the real names of the EmployeesTable table and the ManagerID
Field
strSQL = " SELECT DISTINCT BNY Acct# FROM [Customers_To_Email];"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
' Now loop through list of ManagerID values and create a query foreach
ManagerID
' so that the data can be exported -- the code assumes that the actual
names
' of the managers are in a lookup table -- again, replace generic
names with
' real names of tables and fields
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
' *** code to set strMgr needs to be changed to conform to your
' *** database design -- ManagerNameField, ManagersTable, and
' *** ManagerID need to be changed to your table and field names
' *** be changed to your table and field names
strMgr = DLookup("BNY Acct#", "Customers_To_Email", _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "'")
' *** code to set strSQL needs to be changed to conform to your
' *** database design -- ManagerID and EmployeesTable need to
' *** be changed to your table and field names
strSQL = "SELECT * FROM [Customers_To_Email] WHERE " & _
"BNY Acct# = '" & rstMgr!BNY Acct#.value & "';"
Set qdf = dbs.QueryDefs(strTemp)
qdf.Name = "q_" & strMgr
strTemp = qdf.Name
qdf.SQL = strSQL
qdf.Close
Set qdf = Nothing
strFile = Format$(Date, "Medium Date") & " " & strMgr &
".xls"
strPathFile = strPath & "\" & strFile
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.QueryDefs.Delete strTemp
dbs.Close
Set dbs = Nothing
MsgBox "Individual Files Created.", vbOK, "Status"
End Sub- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
 
E

Erick C

Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"


Erick,

Step 1 copy the module into your database and then type here the name of
your report.  Also make sure you have a default printer assigned to windows.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF.  I do not
know what I am doing, or not doing.  I have no idea how to integrate
the code into my current database.  I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing.  I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object.  The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465':  Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:

Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.

' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean

' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner  - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only

' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.

Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.

I'm here to help... so if step one is getting the ReportToPDF to work
first
then lets do that... What problems are you having getting that code to
work? ANd where are you with it? Have you copied it into a module? Have
you put the .DLL's in place? You get the idea...
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
Erick,
Before I adjust your code... I thought you wanted to use Stephen Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![Customers_To_Email]
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
End Sub
Erick,
Try...
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") &
".rtf"
DoCmd.Close acReport, "YourReport"
Next
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") &
".rtf"
DoCmd.Close acReport, "YourReport"
Next
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to

...

read more »- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

Then put this line behind a button

DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", , "c:\MyTestFile.pdf",
False)

and let me know what the results are. Once we get this working I will
incorporate into other peice of code.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"


Erick,

Step 1 copy the module into your database and then type here the name of
your report. Also make sure you have a default printer assigned to
windows.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:

Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.

' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean

' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only

' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.

Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.

I'm here to help... so if step one is getting the ReportToPDF to work
first
then lets do that... What problems are you having getting that code to
work? ANd where are you with it? Have you copied it into a module? Have
you put the .DLL's in place? You get the idea...
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
Erick,
Before I adjust your code... I thought you wanted to use Stephen
Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![Customers_To_Email]
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
End Sub
Erick,
Try...
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= " & cboCode.ItemData(intCounter)
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") &
".rtf"
DoCmd.Close acReport, "YourReport"
Next
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,
"[YourFieldControlSource]
= '" &
cboCode.ItemData(intCounter) & "'"
DoEvents
DoCmd.OutputTo acReport, "YourReport", acFormatRTF,
"DriveLetter:\FolderName\FileName" & Format(intCounter, "000") &
".rtf"
DoCmd.Close acReport, "YourReport"
Next
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi everybody.
I am hoping someone may be able to help me out. I have a database
report that I want to export into PDF for each individual customer.
Basically, I want to set up a button on my form that will allow the
user to

...

read more »- Hide quoted text -

- Show quoted text -
 
E

Erick C

OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.



Erick,

Then put this line behind a button

DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", , "c:\MyTestFile.pdf",
False)

and let me know what the results are.  Once we get this working I will
incorporate into other peice of code.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Hi Gina -
I have the module in my database.  I have double checked that my
defauly printer is working, everything is printing out of the database
OK.  Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"

Step 1 copy the module into your database and then type here the name of
your report. Also make sure you have a default printer assigned to
windows.
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:
Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.
' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean
' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only
' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.
Erick,
I'm here to help... so if step one is getting the ReportToPDF to work
first
then lets do that... What problems are you having getting that code to
work? ANd where are you with it? Have you copied it into a module? Have
you put the .DLL's in place? You get the idea...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
Erick,
Before I adjust your code... I thought you wanted to use Stephen
Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![Customers_To_Email]
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData (intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
End Sub
Erick,
Try...
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,

...

read more »- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

Okay, one more thing... the combo box that has your eMail addresses in it...

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.



Erick,

Then put this line behind a button

DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", , "c:\MyTestFile.pdf",
False)

and let me know what the results are. Once we get this working I will
incorporate into other peice of code.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"

Step 1 copy the module into your database and then type here the name of
your report. Also make sure you have a default printer assigned to
windows.
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:
Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.
' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean
' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only
' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.
Erick,
I'm here to help... so if step one is getting the ReportToPDF to work
first
then lets do that... What problems are you having getting that code to
work? ANd where are you with it? Have you copied it into a module?
Have
you put the .DLL's in place? You get the idea...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
Erick,
Before I adjust your code... I thought you wanted to use Stephen
Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do
not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![Customers_To_Email]
'If Your Data Type is a String
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "Sweep_Report_For_Email", acViewPreview, ,
"[Customers_To_Email]![AcctNum] " = " & cboCode.ItemData
(intCounter)
& " '"
DoEvents
DoCmd.OutputTo acReport, "Sweep_Report_For_Email", acFormatRTF, "C:
\Users\Erick\Documents\export" & Format(intCounter, "000") & ".rtf"
DoCmd.Close acReport, "YourReport"
Next
End Sub
On Jan 29, 7:59 pm, "Gina Whipp" <[email protected]>
wrote:
Erick,
Try...
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourControl]
'If Your Data Type is Numeric
For intCounter = 0 To cboCode.ListCount - 1
DoCmd.OpenReport "YourReport", acViewPreview, ,

...

read more »- Hide quoted text -

- Show quoted text -
 
E

Erick C

Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.

Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)

On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0

doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)

'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"


Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)

Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)

Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing

ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If

Refresh
MsgBox " Your email has been sent"


Erick,

Okay, one more thing... the combo box that has your eMail addresses in it....

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.

Then put this line behind a button
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", , "c:\MyTestFile.pdf",
False)
and let me know what the results are. Once we get this working I will
incorporate into other peice of code.
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"
Erick,
Step 1 copy the module into your database and then type here the nameof
your report. Also make sure you have a default printer assigned to
windows.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression..
Here is the code I tried to use:
Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.
' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean
' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only
' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path..
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.
Erick,
I'm here to help... so if step one is getting the ReportToPDF to work
first
then lets do that... What problems are you having getting that codeto
work? ANd where are you with it? Have you copied it into a module?
Have
you put the .DLL's in place? You get the idea...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try and
get it to work, though as I mentioned earlier it is a bit complex for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
Erick,
Before I adjust your code... I thought you wanted to use Stephen
Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do
not
know if I actually filled everything out correctly (which I probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox

...

read more »- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

First, pardon the delay.. emergency... Eating dinner will look at this when
I finish.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.

Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
DoCmd.OutputTo acOutputReport, [Sweep_Report_For_Email], _
acFormatPDF, strTemp, strPathFile
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)

On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0

doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)

'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"


Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)

Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)

Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing

ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If

Refresh
MsgBox " Your email has been sent"


Erick,

Okay, one more thing... the combo box that has your eMail addresses in
it...

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.

Then put this line behind a button
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", ,
"c:\MyTestFile.pdf",
False)
and let me know what the results are. Once we get this working I will
incorporate into other peice of code.
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"
Erick,
Step 1 copy the module into your database and then type here the name
of
your report. Also make sure you have a default printer assigned to
windows.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:
Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.
' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean
' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only
' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.
Erick,
I'm here to help... so if step one is getting the ReportToPDF to
work
first
then lets do that... What problems are you having getting that code
to
work? ANd where are you with it? Have you copied it into a module?
Have
you put the .DLL's in place? You get the idea...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try
and
get it to work, though as I mentioned earlier it is a bit complex
for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before
I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
On Jan 30, 10:44 pm, "Gina Whipp" <[email protected]>
wrote:
Erick,
Before I adjust your code... I thought you wanted to use Stephen
Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do
not
know if I actually filled everything out correctly (which I
probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger
highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox

...

read more »- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

First, the report has to drop out to individual files, one way or the
other... So whether you use a combo box or a list box doesn't matter. But
it must loop thru and attach a number or something on to the end of each
file so it knows the reports are seperate entities. Might be better to pick
to pick the CustomerID as the report name so when eMailing the eMail knows
which report to grab. (I can modify to include CustomerID.)

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![YourComboBox]

For intCounter = 0 To Combo0.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[YourFieldControlSource] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", ,
"DriveLetter\FolderName\Sweeps_Report_For_Email" & Format(intCounter, "000")
& ".pdf", False, False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next

The code you supplied below appears to go to one eMail address at a time...
Is this true? I don't have Lotus Notes so no way to test.


--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.

Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)

On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0

doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)

'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"


Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)

Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)

Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing

ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If

Refresh
MsgBox " Your email has been sent"


Erick,

Okay, one more thing... the combo box that has your eMail addresses in
it...

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.

Then put this line behind a button
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", ,
"c:\MyTestFile.pdf",
False)
and let me know what the results are. Once we get this working I will
incorporate into other peice of code.
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"
Erick,
Step 1 copy the module into your database and then type here the name
of
your report. Also make sure you have a default printer assigned to
windows.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I do not
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form and
press the "Click Here to Save this Report as a PDF document" button I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the event procedure code attached to the "Click Here" button from
above.
I tried to modify a few things to get it to work, but nothing doing.
If I try to use the button, I get a Run time error '2465': Microsoft
Office Access can't find the field "I" referred to in your expression.
Here is the code I tried to use:
Private Sub cmdReportToPDF_Click()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.
' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 150, _
'Optional PasswordOpen As String = "", _
'Optional PasswordOwner As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0, _
'Optional PDFUnicodeFlags As Long = 0 _
') As Boolean
' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to
display
' the standard windows File Dialog window to select an exisiting
Snapshot file
' CompressionLevel - Resolution in DPI(Dots per Inch) to apply to
embedded Images
' PasswordOpen - Users require to Open PDF
' PasswordOwner - Users require to modify PDF
' PasswordRestrictions - Restrictions for viewing/editing/printing PDF
- See modReportToPDF for comments
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the
PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts
are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only
' PDFUnicodeFlags controls how each metafile text record is
interpreted in terms
' of Unicode and BiDi language. See modDocumentor for details.
'
' You must pass either RptName or SnapshotName or set the
ShowSaveFileDialog param to TRUE.
' Any file names you pass to this function must include the full path.
If you only include the
' filename for the output PDF then your document will be saved to your
My Documents folder.
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this
example.
blRet = ConvertReportToPDF([Sweep_Report_For_Email], vbNullString, _
"Sweep_Report_For_Email" & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the
name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to
TRUE.
Erick,
I'm here to help... so if step one is getting the ReportToPDF to
work
first
then lets do that... What problems are you having getting that code
to
work? ANd where are you with it? Have you copied it into a module?
Have
you put the .DLL's in place? You get the idea...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
I tried to figure out how to use ReportToPDF because in my digging
around online it seemed to be mentioned as the best way to export
reports to PDF. I do not have any preference as to where the code
comes from as long as it works correctly. If I need to use
ReportToPDF then I will keep plugging away at his database to try
and
get it to work, though as I mentioned earlier it is a bit complex
for
my level of understanding. I wanted to see if there was anyone who
had a code that achieved the same results that I could modify before
I
spent a ton of effort trying to figure out the ReportToPDF database,
and eventually coming back here for help anyway. I just came here
first, that's all.
On Jan 30, 10:44 pm, "Gina Whipp" <[email protected]>
wrote:
Erick,
Before I adjust your code... I thought you wanted to use Stephen
Leban's
ReportToPDF?
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
Thanks for the response.
I tried to use your code, but I have run into some problems. I do
not
know if I actually filled everything out correctly (which I
probably
did not since I am still kind of new at this stuff).
Here is the code that I tried to use, it gave me a compile error,
saying "Can't find project or library." and the debugger
highlights
Format in the docmd.OutputTo line.
Private Sub CreatePDF_Click()
Dim intCounter As Integer
Dim cboCode As ComboBox

...

read more »- Hide quoted text -

- Show quoted text -
 
E

Erick C

Gina -
I am not the biggest fan of Lotus Notes myself, this would be so much
easier if I was using Outlook. Regarding your email code question,
yes you are correct. The code as it is written emails only one
address at a time. I had guessed that it would be better and easier
to integrate into another code. I also added a list box to my form
that pulls in the customer ID (AcctNum), customer name, and email
address.
I thought that the same list box could be used to pull an email
address right after it was used to create and name the pdf. So, the
identifying portion of the name of the file would come from the
customer ID column in the list box, then the email address from the
email section of the list box. SO basically right after a pdf is made
it is emailed and then it moves on to the next customer ID in the list
box. Does my weird thought process make any sense at all, or was I
way off?

OK, I have changed the code attached to the button, but I have
received an error saying Compile error: can't find project or
library. The debugger highlights Format at the beginning of "Format
(intCounter,"000")"
Here is what my code looks like, did I add something that I was not
supposed to?

Dim intCounter As Integer
Dim cboCode As ComboBox


Set cboCode = Me![CustomerListBox]


For intCounter = 0 To CustomerListBox.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[AcctNum] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", , "C:\Users\Erick\Documents\Test
\Sweeps_Report_For_Email" & Format(intCounter, "000") & ".pdf", False,
False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next




Erick,

First, the report has to drop out to individual files, one way or the
other...  So whether you use a combo box or a list box doesn't matter.  But
it must loop thru and attach a number or something on to the end of each
file so it knows the reports are seperate entities.  Might be better topick
to pick the CustomerID as the report name so when eMailing the eMail knows
which report to grab.  (I can modify to include CustomerID.)

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![YourComboBox]

For intCounter = 0 To Combo0.ListCount - 1
  DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[YourFieldControlSource] = '" & cboCode.ItemData(intCounter) & "'"
  DoEvents
  Call ConvertReportToPDF("Report1", ,
"DriveLetter\FolderName\Sweeps_Report_For_Email" & Format(intCounter, "000")
& ".pdf", False, False)
  DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next

The code you supplied below appears to go to one eMail address at a time....
Is this true?  I don't have Lotus Notes so no way to test.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table.  The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table.  The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.

Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)

On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0

doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)

'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"

Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department.  If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)

Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
    doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)

Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing

ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If

Refresh
MsgBox " Your email has been sent"

Okay, one more thing... the combo box that has your eMail addresses in
it...
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.

...

read more »- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

Is it looking at a text field or a numeric field?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina -
I am not the biggest fan of Lotus Notes myself, this would be so much
easier if I was using Outlook. Regarding your email code question,
yes you are correct. The code as it is written emails only one
address at a time. I had guessed that it would be better and easier
to integrate into another code. I also added a list box to my form
that pulls in the customer ID (AcctNum), customer name, and email
address.
I thought that the same list box could be used to pull an email
address right after it was used to create and name the pdf. So, the
identifying portion of the name of the file would come from the
customer ID column in the list box, then the email address from the
email section of the list box. SO basically right after a pdf is made
it is emailed and then it moves on to the next customer ID in the list
box. Does my weird thought process make any sense at all, or was I
way off?

OK, I have changed the code attached to the button, but I have
received an error saying Compile error: can't find project or
library. The debugger highlights Format at the beginning of "Format
(intCounter,"000")"
Here is what my code looks like, did I add something that I was not
supposed to?

Dim intCounter As Integer
Dim cboCode As ComboBox


Set cboCode = Me![CustomerListBox]


For intCounter = 0 To CustomerListBox.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[AcctNum] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", , "C:\Users\Erick\Documents\Test
\Sweeps_Report_For_Email" & Format(intCounter, "000") & ".pdf", False,
False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next




Erick,

First, the report has to drop out to individual files, one way or the
other... So whether you use a combo box or a list box doesn't matter. But
it must loop thru and attach a number or something on to the end of each
file so it knows the reports are seperate entities. Might be better to
pick
to pick the CustomerID as the report name so when eMailing the eMail knows
which report to grab. (I can modify to include CustomerID.)

'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![YourComboBox]

For intCounter = 0 To Combo0.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[YourFieldControlSource] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", ,
"DriveLetter\FolderName\Sweeps_Report_For_Email" & Format(intCounter,
"000")
& ".pdf", False, False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next

The code you supplied below appears to go to one eMail address at a
time...
Is this true? I don't have Lotus Notes so no way to test.

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.

Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)

On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0

doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)

'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"

Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)

Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)

Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing

ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If

Refresh
MsgBox " Your email has been sent"

Okay, one more thing... the combo box that has your eMail addresses in
it...
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.

...

read more »- Hide quoted text -

- Show quoted text -
 
E

Erick C

Good morning Gina!
AcctNum is a text field.


Erick,

Is it looking at a text field or a numeric field?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm


Gina -
I am not the biggest fan of Lotus Notes myself, this would be so much
easier if I was using Outlook.  Regarding your email code question,
yes you are correct.  The code as it is written emails only one
address at a time.  I had guessed that it would be better and easier
to integrate into another code.   I also added a list box to my form
that pulls in the customer ID (AcctNum), customer name, and email
address.
I thought that the same list box could be used to pull an email
address right after it was used to create and name the pdf.  So, the
identifying portion of the name of the file would come from the
customer ID column in the list box, then the email address from the
email section of the list box.  SO basically right after a pdf is made
it is emailed and then it moves on to the next customer ID in the list
box.  Does my weird thought process make any sense at all, or was I
way off?

OK, I have changed the code attached to the button, but I have
received an error saying Compile error: can't find project or
library.  The debugger highlights Format at the beginning of "Format
(intCounter,"000")"
Here is what my code looks like, did I add something that I was not
supposed to?

Dim intCounter As Integer
Dim cboCode As ComboBox

Set cboCode = Me![CustomerListBox]

For intCounter = 0 To CustomerListBox.ListCount - 1
  DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[AcctNum] = '" & cboCode.ItemData(intCounter) & "'"
  DoEvents
  Call ConvertReportToPDF("Report1", , "C:\Users\Erick\Documents\Test
\Sweeps_Report_For_Email" & Format(intCounter, "000") & ".pdf", False,
False)
  DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next

First, the report has to drop out to individual files, one way or the
other... So whether you use a combo box or a list box doesn't matter. But
it must loop thru and attach a number or something on to the end of each
file so it knows the reports are seperate entities. Might be better to
pick
to pick the CustomerID as the report name so when eMailing the eMail knows
which report to grab. (I can modify to include CustomerID.)
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourComboBox]
For intCounter = 0 To Combo0.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[YourFieldControlSource] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", ,
"DriveLetter\FolderName\Sweeps_Report_For_Email" & Format(intCounter,
"000")
& ".pdf", False, False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next
The code you supplied below appears to go to one eMail address at a
time...
Is this true? I don't have Lotus Notes so no way to test.
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.
Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)
On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0
doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)
'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"
Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)
Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If
Refresh
MsgBox " Your email has been sent"

...

read more »- Hide quoted text -

- Show quoted text -
 
E

Erick C

Gina -
Sorry, I had an error in my code. I fixed it and the code now creates
individual pdf files for each customer. The file is named
"Sweeps_Report_For_Email000.pdf" and "Sweeps_Report_For_Email001.pdf"


Good morning Gina!
AcctNum is a text field.

Is it looking at a text field or a numeric field?
"I feel I have been denied critical, need to know, information!" - Tremors
II

"Erick C" <[email protected]> wrote in message
Gina -
I am not the biggest fan of Lotus Notes myself, this would be so much
easier if I was using Outlook.  Regarding your email code question,
yes you are correct.  The code as it is written emails only one
address at a time.  I had guessed that it would be better and easier
to integrate into another code.   I also added a list box to my form
that pulls in the customer ID (AcctNum), customer name, and email
address.
I thought that the same list box could be used to pull an email
address right after it was used to create and name the pdf.  So, the
identifying portion of the name of the file would come from the
customer ID column in the list box, then the email address from the
email section of the list box.  SO basically right after a pdf is made
it is emailed and then it moves on to the next customer ID in the list
box.  Does my weird thought process make any sense at all, or was I
way off?
OK, I have changed the code attached to the button, but I have
received an error saying Compile error: can't find project or
library.  The debugger highlights Format at the beginning of "Format
(intCounter,"000")"
Here is what my code looks like, did I add something that I was not
supposed to?
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![CustomerListBox]
For intCounter = 0 To CustomerListBox.ListCount - 1
  DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[AcctNum] = '" & cboCode.ItemData(intCounter) & "'"
  DoEvents
  Call ConvertReportToPDF("Report1", , "C:\Users\Erick\Documents\Test
\Sweeps_Report_For_Email" & Format(intCounter, "000") & ".pdf", False,
False)
  DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next
Erick,
First, the report has to drop out to individual files, one way or the
other... So whether you use a combo box or a list box doesn't matter.But
it must loop thru and attach a number or something on to the end of each
file so it knows the reports are seperate entities. Might be better to
pick
to pick the CustomerID as the report name so when eMailing the eMail knows
which report to grab. (I can modify to include CustomerID.)
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourComboBox]
For intCounter = 0 To Combo0.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[YourFieldControlSource] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", ,
"DriveLetter\FolderName\Sweeps_Report_For_Email" & Format(intCounter,
"000")
& ".pdf", False, False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next
The code you supplied below appears to go to one eMail address at a
time...
Is this true? I don't have Lotus Notes so no way to test.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.
Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)
On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0
doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)
'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"
Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)
Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If
Refresh
MsgBox " Your email has been sent"
Erick,
Okay, one more thing... the combo box that has your eMail addressesin
it...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.
Erick,
Then put this line behind a button
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", ,
"c:\MyTestFile.pdf",
False)
and let me know what the results are. Once we get this working I will
incorporate into other peice of code.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"
Erick,
Step 1 copy the module into your database and then type here the
name
of
your report. Also make sure you have a default printer assignedto
windows.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gnia -
I apologize for the delay in my response, busy time for me at work.
I cannot seem to get anything going with this ReportToPDF. I donot
know what I am doing, or not doing. I have no idea how to integrate
the code into my current database. I am just plain lost and becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same
folder
in My Documents along with my created database that I am testing. I
just don't know what I am doing wrong, or how I am supposed to use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the formand
press the "Click Here to Save this Report as a PDF document" button
I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then copied
the

...

read more »- Hide quoted text -

- Show quoted text -
 
G

Gina Whipp

Erick,

Okay... now the we need to find a way to identify the report for each
Customer... I suggested using the CustomerID is that an option for you?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

Gina -
Sorry, I had an error in my code. I fixed it and the code now creates
individual pdf files for each customer. The file is named
"Sweeps_Report_For_Email000.pdf" and "Sweeps_Report_For_Email001.pdf"


Good morning Gina!
AcctNum is a text field.

Is it looking at a text field or a numeric field?
"I feel I have been denied critical, need to know, information!" -
Tremors
II

"Erick C" <[email protected]> wrote in message
Gina -
I am not the biggest fan of Lotus Notes myself, this would be so much
easier if I was using Outlook. Regarding your email code question,
yes you are correct. The code as it is written emails only one
address at a time. I had guessed that it would be better and easier
to integrate into another code. I also added a list box to my form
that pulls in the customer ID (AcctNum), customer name, and email
address.
I thought that the same list box could be used to pull an email
address right after it was used to create and name the pdf. So, the
identifying portion of the name of the file would come from the
customer ID column in the list box, then the email address from the
email section of the list box. SO basically right after a pdf is made
it is emailed and then it moves on to the next customer ID in the list
box. Does my weird thought process make any sense at all, or was I
way off?
OK, I have changed the code attached to the button, but I have
received an error saying Compile error: can't find project or
library. The debugger highlights Format at the beginning of "Format
(intCounter,"000")"
Here is what my code looks like, did I add something that I was not
supposed to?
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![CustomerListBox]
For intCounter = 0 To CustomerListBox.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[AcctNum] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", , "C:\Users\Erick\Documents\Test
\Sweeps_Report_For_Email" & Format(intCounter, "000") & ".pdf", False,
False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next
Erick,
First, the report has to drop out to individual files, one way or the
other... So whether you use a combo box or a list box doesn't matter.
But
it must loop thru and attach a number or something on to the end of
each
file so it knows the reports are seperate entities. Might be better to
pick
to pick the CustomerID as the report name so when eMailing the eMail
knows
which report to grab. (I can modify to include CustomerID.)
'Posted by ADezii 5.23.2009 on bytes.com
'Modified by Gina Whipp 11.4.2009 to OutputTo Multiple Files
'Tested in Access 2003
Dim intCounter As Integer
Dim cboCode As ComboBox
Set cboCode = Me![YourComboBox]
For intCounter = 0 To Combo0.ListCount - 1
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview, ,
"[YourFieldControlSource] = '" & cboCode.ItemData(intCounter) & "'"
DoEvents
Call ConvertReportToPDF("Report1", ,
"DriveLetter\FolderName\Sweeps_Report_For_Email" & Format(intCounter,
"000")
& ".pdf", False, False)
DoCmd.Close acReport, "Sweeps_Report_For_Email"
Next
The code you supplied below appears to go to one eMail address at a
time...
Is this true? I don't have Lotus Notes so no way to test.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Gina -
The email addresses are not actually part of a combo box on my form, I
just have them all in a Customers_To_Email table. The field is "Email
Address" in the table.
I need to somehow set up a loop with the code so an individual report
is created for each customer in the table. The test PDF that was
created has all customers in it, which would not be too cool at all.
I also have a working code for emailing out of Lotus Notes, though I
do not know how to integrate it into the PDF code, but maybe it can
help.
Dim s As Object
Dim db As Object
Dim doc As Object
Dim rtItem As Object
Dim Server As String, Database As String
Dim strError As String
'startup Lotus notes and get object handle
Set s = CreateObject("Notes.notesSession")
Server = s.GETENVIRONMENTSTRING("MailServer", True)
Database = s.GETENVIRONMENTSTRING("MailFile", True)
Set db = s.GetDatabase(Server, Database)
On Error GoTo ErrorLogon
'see if user is logged on
Set doc = db.CreateDocument
On Error GoTo 0
doc.Form = "Memo"
doc.importance = "1" '(Where 1=Urgent, 2= Normal, 3= FYI)
'Send an e-mail to
doc.sendTO = "email address goes here"
doc.RETURNRECEIPT = "1"
doc.Subject = "Test Email"
Set rtItem = doc.CreateRichTextItem("Body")
Call rtItem.AppendText("Test Email")
Call rtItem.AddNewLine(2)
Call rtItem.AppendText("Dear sir or madam")
Call rtItem.AddNewLine(1)
Call rtItem.AppendText("This is a test email for the Treasury
Department. If you have received this in error, please disregard and
delete. ")
Call rtItem.AddNewLine(2)
Call rtItem.EMBEDOBJECT(1454, "", "G:\treas\Erick\Sweep Test Docs
\rates.xls")
doc.SaveMessageOnSend = True
doc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
Call doc.Send(False)
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
ErrorLogon:
If Err.Number = 7063 Then
MsgBox " You must first logon to Lotus Notes"
Set doc = Nothing
Set db = Nothing
Set s = Nothing
Set rtItem = Nothing
End If
Refresh
MsgBox " Your email has been sent"
Erick,
Okay, one more thing... the combo box that has your eMail addresses
in
it...
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
OK, the button opened up the report in preview view in access and
created a pdf file in my test folder (I modified the path in your
code) named MyTestFile.pdf, and the adobe viewer opened up.
Erick,
Then put this line behind a button
DoCmd.OpenReport "Sweeps_Report_For_Email", acViewPreview
Call ConvertReportToPDF("Sweeps_Report_For_Email", ,
"c:\MyTestFile.pdf",
False)
and let me know what the results are. Once we get this working I
will
incorporate into other peice of code.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gina -
I have the module in my database. I have double checked that my
defauly printer is working, everything is printing out of the
database
OK. Double checked to make sure it was not set up to the Adobe PDF
writer.
My report is "Sweeps_Report_For_Email"
On Feb 2, 1:44 pm, "Gina Whipp" <[email protected]>
wrote:
Erick,
Step 1 copy the module into your database and then type here the
name
of
your report. Also make sure you have a default printer assigned
to
windows.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know,
information!" -
Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Hi Gnia -
I apologize for the delay in my response, busy time for me at
work.
I cannot seem to get anything going with this ReportToPDF. I do
not
know what I am doing, or not doing. I have no idea how to
integrate
the code into my current database. I am just plain lost and
becoming
frustrated, sadly.
I have copied the database and the two DLL files into the same
folder
in My Documents along with my created database that I am
testing. I
just don't know what I am doing wrong, or how I am supposed to
use
this ReportToPDF database.
If I just open the ReportToPDF database and try to use the form
and
press the "Click Here to Save this Report as a PDF document"
button
I
get an error saying SnapshotToPDF: 2213 - There was a problem
retrieving printer information for this object. The object may
have
been sent to a printer that is unavailable.
I cannot seem to figure out what printer this report is pointing
at.
My default network printer is set up correctly.
I also imported all of the modules into my own database, then
copied
the

...

read more »- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top