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
> Setting A Report Filter Then Printing It Out In VBA, Access 2013    
 
   
ry94080
post Jan 11 2018, 04:07 PM
Post#1



Posts: 956
Joined: 27-July 05



Hi all,

I'm trying to write my VBA to open up a report, set a filter, then print it out.

It seems not to be pulling in the data when it prints out. Am I missing something?

CODE
            DoCmd.OpenReport "PendingLog_by_Date", acViewDesign
            Reports("PendingLog_by_Date").FilterOn = True
            Reports("PendingLog_by_Date").Filter = "[FDR]< #" & (Date) & " " & Mid(Forms("frmPendingLogParameters").Controls("txtCutOffTime").Value, 1, 2) & ":" & Mid(Forms("frmPendingLogParameters").Controls("txtCutOffTime").Value, 3, 2) & "#" & " or " & "[FinalDestinationReceived] = 'Not FDRd'"
            DoCmd.Close acReport, "PendingLog_by_Date", acSaveYes
            DoCmd.OpenReport "PendingLog_by_Date", acViewNormal
Go to the top of the page
 
theDBguy
post Jan 11 2018, 04:10 PM
Post#2


Access Wiki and Forums Moderator
Posts: 72,439
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Have you tried simply using the WhereCondition argument of the OpenReport method?

For example:

strCriteria = "CompanyName='Microsoft'"

DoCmd.OpenReport "ReportName", , , strCriteria

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
ry94080
post Jan 11 2018, 05:43 PM
Post#3



Posts: 956
Joined: 27-July 05



That worked thanks!
Go to the top of the page
 
theDBguy
post Jan 11 2018, 05:47 PM
Post#4


Access Wiki and Forums Moderator
Posts: 72,439
Joined: 19-June 07
From: SunnySandyEggo


You're welcome. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd June 2018 - 06:44 AM