By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

Error when emailing a parameter query report

P: 86
Hi there..

So i am trying to email a parameter query report that takes in a date formatted to m/yyyy and compiles a report based on the specific month and year.

however, when i click the command button to email the report, the input box window pops up, i type in a month and year, say 6/2010, then hit enter and then it breaks into the following code highlighting it yellow:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strDestination & strReportName & ".pdf", False
the error message is:

Run-time error 2501
The OutputTo action was canceled.

I wonder what caused the program to cancel the action?

This is the query

Expand|Select|Wrap|Line Numbers
  1. SELECT user_problem_log.trouble_no AS [Trouble #], user_problem_log.date_closed AS [Date Closed], user_problem_log.user AS [User], user_problem_log.problem_catergory AS [Problem Category], StrConv([brief_problem],3) AS [Brief Problem], user_problem_log.status AS Status
  2. FROM user_problem_log
  3. WHERE (((Format([user_problem_log.date_closed],"m/yyyy"))=Format([Enter Month and Year],"m/yyyy")))
  4. ORDER BY user_problem_log.problem_catergory;
and the report was created using that query.
Aug 10 '11 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 10K+
P: 12,359
First thing first, does that query work by itself?

I suspect not. Format expects a date. A string in the format of m/yyyy is not a valid date string. And since you are passing a string, you would still need to convert that string to a date first. But that's moot, there's no need to convert the user input to a date and then to m/yyyy since they will be entering it in that format anyways.
Aug 10 '11 #2

P: 86

Yes the query works.

i know what's the problem lol.. it's the naming convention..

i put a "/" in the query name and report and windows file names cannot have a / in the name... so what access did was replaced the / with a _ and that changed the whole report name, hence it was canceled.

Problem Solved!

Aug 10 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.