Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-01-2017, 12:20 AM   #1
farhanleos
Newly Registered User
 
Join Date: Oct 2017
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
farhanleos is on a distinguished road
Exclamation Error on Executing Report based on query and with filtered criteria ..

Greetings ,

Gentlemen i am using below code on all command buttons to execute the report in pdf format , but i got Error while i did the same with the report which is based on Query and i have filter criteria on query?
Please guide if anybody have solution for this

ERROR : Runtime Error '2509'
MicrosoftAccess cannot find the object '|1'.
on Debug it leads to this script
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFilePath

Actual script using for :
Private Sub Command50_Click()
''''Open C1 Projects Under P&TSD/CPM Report in Pdf'''
'initialize variables
Dim strReportName As String
Dim strPathUser As String
Dim strFilePath As String
'set variables
strReportName = "006-C1 Projects Under P&TSD-CPM"
strPathUser = Environ$("USERPROFILE") & "\my documents"
strFilePath = strPathUser & strReportName & Format(Date, "yyyymmdd") & ".pdf"
'export to PDF/EXCEL
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFilePath
'launch excel file
Dim Shex As Object
Set Shex = CreateObject("Shell.Application")
Shex.Open (strFilePath)
End Sub

farhanleos is offline   Reply With Quote
Old 11-01-2017, 12:57 AM   #2
Gasman
Enthusiastic Amateur
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 3,056
Thanks: 341
Thanked 513 Times in 495 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Error on Executing Report based on query and with filtered criteria ..

I am going to hazard a guess that strReportname has |1 as a value.
use debug to walk through the code step by step.
__________________
Access novice. Sometimes trying to give something back.
Access 2007


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 11-01-2017, 01:10 AM   #3
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 8,346
Thanks: 100
Thanked 2,148 Times in 1,993 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Error on Executing Report based on query and with filtered criteria ..

As well as debugging, check whether
- that report exists
- that folder path exists on your computer
Either of those being missing would cause the error

Also you appear to be using Excel to open PDF files.
I didn't know Excel could do that.
It seems an odd choice even if its possible.

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 11-01-2017, 02:00 AM   #4
arnelgp
Registered User
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 6,982
Thanks: 56
Thanked 2,239 Times in 2,149 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Error on Executing Report based on query and with filtered criteria ..

Error on this part:
strPathUser = Environ$("USERPROFILE") & "\my documents"

Should be:
strPathUser = Environ$("USERPROFILE") & "\Documents"
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 11-01-2017, 05:28 AM   #5
farhanleos
Newly Registered User
 
Join Date: Oct 2017
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
farhanleos is on a distinguished road
Re: Error on Executing Report based on query and with filtered criteria ..

Quote:
Originally Posted by arnelgp View Post
Error on this part:
strPathUser = Environ$("USERPROFILE") & "\my documents"

Should be:
strPathUser = Environ$("USERPROFILE") & "\Documents"
sir, you are right i think inplace of my documents only docuemtns
but i check my all existing reports which i am poplulating by other command button are the same with my documents and
those are working
farhanleos is offline   Reply With Quote
Old 11-01-2017, 05:33 AM   #6
farhanleos
Newly Registered User
 
Join Date: Oct 2017
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
farhanleos is on a distinguished road
Re: Error on Executing Report based on query and with filtered criteria ..

Sir I update the code but having same error & it leads me to
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFilePath


Private Sub Command50_Click()
''''Open C1 Projects Under P&TSD/CPM Report in Pdf'''
'initialize variables
Dim strReportName As String
Dim strPathUser As String
Dim strFilePath As String
'set variables
strReportName = "006-C1 Projects Under P&TSD-CPM"
strPathUser = Environ$("USERPROFILE") & "\Documents"
strFilePath = strPathUser & strReportName & Format(Date, "yyyymmdd") & ".pdf"
'export to PDF/EXCEL
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFilePath
'launch excel file
Dim Shex As Object
Set Shex = CreateObject("Shell.Application")
Shex.Open (strFilePath)
End Sub
farhanleos is offline   Reply With Quote
Old 11-01-2017, 07:36 AM   #7
Gasman
Enthusiastic Amateur
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 3,056
Thanks: 341
Thanked 513 Times in 495 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Error on Executing Report based on query and with filtered criteria ..

What does Debug.Print show ???

Code:
Private Sub Command50_Click()
''''Open C1 Projects Under P&TSD/CPM Report in Pdf'''
'initialize variables
Dim strReportName As String
Dim strPathUser As String
Dim strFilePath As String
'set variables
strReportName = "006-C1 Projects Under P&TSD-CPM"
strPathUser = Environ$("USERPROFILE") & "\Documents"
strFilePath = strPathUser & strReportName & Format(Date, "yyyymmdd") & ".pdf"
'export to PDF/EXCEL

Debug.Print strReportName
Debug.Print strFilePath

DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFilePath
'launch excel file
Dim Shex As Object
Set Shex = CreateObject("Shell.Application")
Shex.Open (strFilePath)
End Sub


__________________
Access novice. Sometimes trying to give something back.
Access 2007


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a report based on filtered subform HRakibul Reports 2 01-23-2015 02:50 PM
Report based on filtered form caferacer Forms 8 11-27-2014 12:06 AM
Error when executing OnOpen report ZikO Modules & VBA 3 09-08-2013 10:18 PM
Displaying search criteria on filtered report richary Reports 2 08-14-2008 08:03 AM
[SOLVED] Report based on filtered forms? geir_are Forms 1 11-16-2001 10:34 AM




All times are GMT -8. The time now is 05:57 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World