I have a Certificate of Achievement report, based on a query. When I run the report, the certificate shows the person Nickname and Lastname and a text type ID# (called ON#...it is a unique text type ID).
When I export the report to individual pdfs, I have 2 problems:
1. The report prompts for each individual person, which is tedious
2. The exported report certificate is missing their name and ID# (It appears in the regular multi-page report, so not sure why this is happening)
The query is called: q_Certificates_To_Email
Code:
SELECT t_Restart_Teaching.[ON#], q_Contacts_Extended.FileAs, q_Contacts_Extended.[Last Name] & "_" & [Nickname] AS FullName, t_Restart_Teaching.[Emailed_Instructor_Good_To_Go?], t_Restart_Teaching.Date_Emailed, q_Contacts_Extended.[Home Email], t_Restart_Teaching.[Insurance Pd], t_Restart_Teaching.[Good To Go], t_Restart_Teaching.Notes, q_Contacts_Extended.Nickname, q_Contacts_Extended.[Last Name], t_Restart_Teaching.[Last Name] AS LName
FROM t_Restart_Teaching INNER JOIN q_Contacts_Extended ON t_Restart_Teaching.[ON#] = q_Contacts_Extended.[ON#]
WHERE (((t_Restart_Teaching.[Emailed_Instructor_Good_To_Go?])=Yes) AND ((t_Restart_Teaching.[Insurance Pd])="Yes") AND ((t_Restart_Teaching.[Good To Go])="Yes"))
ORDER BY q_Contacts_Extended.Nickname, t_Restart_Teaching.[Last Name];
The form f_Certificates, is bound to the query above. It has a command button named: cmd_Output_Certificates_To_Individual_PDFs
The on click event code is:
Code:
Private Sub cmd_Output_Certificates_To_Individual_PDFs_Click() Dim rs As DAO.Recordset
Dim sFolder As String
Dim sFile As String
Dim MyDB As DAO.Database
'On Error GoTo Error_Handler
sFolder = Application.CurrentProject.path & "\"
'Set rs = CurrentDb.OpenRecordset("SELECT FullName,Nickname,LName FROM q_Certificates_To_Email", dbOpenSnapshot)
Set MyDB = CurrentDb
Set rs = MyDB.OpenRecordset("q_Certificates_To_Email")
With rs
.MoveFirst
Do While Not .EOF
DoCmd.OpenReport "r_Certificates", acViewPreview, , "[LName]=" & ![LName], acHidden
'sFile = Nz(![FirstName], "") & "_" & Nz(![LName], "") & ".pdf"
sFile = Nz(![Nickname], "") & "_" & Nz(![LName], "") & "_Restart_Certificate" & ".pdf"
sFile = sFolder & sFile
DoCmd.OutputTo acOutputReport, "r_Certificates", acFormatPDF, sFile, , , , acExportQualityPrint
'If you wanted to create an e-mail and include an individual report, you would do so now
DoCmd.Close acReport, "r_Certificates"
.MoveNext
Loop
End With
Application.FollowHyperlink sFolder 'Optional / Open the folder housing the files
Error_Handler_Exit:
On Error Resume Next
If Not rs Is Nothing Then
rs.Close
Set rs = Nothing
End If
Exit Sub
Error_Handler:
If Err.Number <> 2501 Then 'Let's ignore user cancellation of this action!
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: cmd_Output_Certificates_To_Individual_PDFs" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occured!"
End If
Resume Error_Handler
End Sub
I need to email these certificates and I am way overdue having tried so many different variations on the internet. can anybody help me ? I can attach a db if required...
Thanks SO MUCH,
Oblio