Email Current Record in PDF format

michelecobb

New member
Local time
Today, 12:14
Joined
May 23, 2013
Messages
4
I am new to Access. I am using Access 2010. I have searched and found several articles on emailing the current record shown on a form but haven't been able to get any of them to work.

My goal is to have a user input information onto the form and then have one button the user will click that will save the current record, email the current record in pdf, and then close the form.

The form name is: frmCorrectiveActions. The unique identifier for a record is: Corrective Action ID.

The last coding I tried is below. I know something is wrong but have copied this code from another post about emailing forms so I'm not even sure what half of it means. I am getting the message Run-time error '3075': Syntax error (missing operator) in query expression "Corrective Actions ID = 23' and when I hit debug this is highlighted: qry.SQL = strSQL

form Private Sub Email_Click()
Dim qry As DAO.QueryDef
Dim strSQL As String
Dim ReportQueryName As String
ReportQueryName = "qryCorrectiveActions"
Set qry = CurrentDb.QueryDefs(ReportQueryName)
strSQL = "SELECT * FROM tblCorrectiveActions WHERE Corrective Actions ID = " & Me.Corrective_Action_ID
qry.SQL = strSQL
DoCmd.Requery [qryCorrectiveActions]
DoCmd.SendObject acSendForm, frmCorrectiveActions, acFormatPDF, "variable", , , _
"Corrective Actions", "Attached please find Corrective Actions notification"

End Sub

Any help would be greatly appreciated!
 
Last edited:
Because of the inadvisable spaces, you have to bracket the field name:

strSQL = "SELECT * FROM tblCorrectiveActions WHERE [Corrective Actions ID] = " & Me.Corrective_Action_ID
 
Ok - added the [brackets] and now I'm getting Run-time error '2465': MS Access can't find the field '|1' referred to in your expression. When I hit debug DoCmd.Requery [qryCorrectiveActions] is highlighted.

Any ideas?
 
Are you sure of the name of the textbox, or might it also have spaces?
 
The query name is qryCorrectiveActions with no spaces if that's what you mean by the name of the textbox.
 
I'm sorry, you don't need that line at all.
 

Users who are viewing this thread

Back
Top Bottom