Hopefully someone can help me figure this one out.
I have one table with almost 2K records in it.
I want the user to be able to print a specific record.
In an Access DB I found I was able to copy the code and get it to work.
I have included the code below.
What I really need to be able to do is not just print a specific record, but to be able to output it in .pdf
so that it can be either printed or more importantly, saved and emailed as an attachment.
I have tried to write a macro that will output to .pdf and can choose the specific report, in this case the report name; “VEH_RECD’ but it will output 2K records in .pdf, not just the one specific one that is being viewed in the form in that time.
Any ideas?
Private Sub cmdPrintPreview_Click()
Dim strReportName As String
Dim strCriteria As String
If NewRecord Then
MsgBox "This record contains no data. Please select a record to print or Save this record." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "rptSalespersonContact"
strCriteria = "[lngSalespersonID]= " & Me![lngSalespersonID]
'strCriteria = "[lngSalespersonID]='" & Me![lngSalespersonID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
End If
End Sub