UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Generate Pdf With Filter, 2010    
 
   
SlayerNL
post Jan 28 2016, 02:33 AM
Post#1



Posts: 3
Joined: 26-January 16



Hi,

I'm struggling for a while with code to generate 1 invoice as pdf and add this to an e-mail message.

I have a lstselection to select the invoice but when I click the button, Access generates a pdf with all the invoices.

This is the code (all found on this site):

I declared a public gFactuurID as Long

and on opening the report "Factuur" I use this code:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = "FactuurID= " & gFactuurID
Me.FilterOn = True
End Sub

This is the code for the 'email button':

Private Sub kn_emailen_Click()
On Error GoTo Err_kn_emailen_Click
Dim strDocName As String

strDocName = "Factuur"

'DoCmd.OpenReport strDocName, acPreview, "FactuurId =" & Me.lstSelection.Column(3), , acHidden
gFactuurID = Me.lstSelection.Column(3)
DoCmd.SendObject acSendReport, strDocName, acFormatPDF, Me.lstSelection.Column(8), , , "Our invoice no:", "Text in Body", True
DoCmd.Close acReport, "CurrentRecord"
Exit_kn_emailen_Click:
Exit Sub

Err_kn_emailen_Click:
MsgBox Err.Description
Resume Exit_kn_emailen_Click

End Sub

Any help would be great ....
Go to the top of the page
 
azolder
post Jan 28 2016, 07:08 AM
Post#2



Posts: 2,428
Joined: 12-February 15
From: SW AZ


Where did you declare gFactuurID? With your usage in Report_Open it should be in a standard module.

EDIT:
Beyond that, what is your report's record source (the fields)? Does FactuurID identify a unique record?
Go to the top of the page
 
SlayerNL
post Jan 28 2016, 08:29 AM
Post#3



Posts: 3
Joined: 26-January 16



That's the solution !

I declared gFactuurID within the report as public. I now declared it in a Module and it works !!

Thanks very much!
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    14th December 2017 - 10:20 AM