This is driving me mad.
I have an activity report with the option to print, view on screen or email.
Both the Print and on screen options correctly filter the report between 2 dates but the pdf produced to be email ignores the filter and has ALL the transactions.
I have many similar constructs elsewhere which seem to work - so why this defies logic I don't know !!
Thank you
Code:
wHereFilter = "(tblTempCustomerTransactions.Date) Between [Forms]![fdlgCustomerActivityA]![txtDateFrom] And [Forms]![fdlgCustomerActivityA]![txtDateTo]"
< if printer - just same as screen except acNormal>
ElseIf [cboPrintDestination] = "Screen" Then DoCmd.OpenReport "repCustomerActivityHistory", acPreview, , wHereFilter
Else
gEmailAddress = wEmail
gEmailSubject = "xxxxx"
gEmailMessage = "Please see attached Customer Activity Report"
strFolder = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
strFile = "CustomerActivity.pdf"
strPath = strFolder & strFile
DoCmd.OpenReport "repCustomerActivityHistory", acViewDesign, , , acHidden
Reports![repCustomerActivityHistory].Filter = wHereFilter
DoCmd.Close acReport, "repCustomerActivityHistory", acSaveYes
DoCmd.OutputTo acOutputReport, "repCustomerActivityHistory", acFormatPDF, strPath, False