printing error handling issue? (when clicking cancel get 2501 error)

I have a report that when it is closed the

DoCmd RunCommand acCmdPrint    occurs ... but of course if the user clicks 
cancel, it gives me

a 2501 error.

How & where do I put code to surpress this error. I would just the close 
even to run the
DoCmd RunCommand acCmdPrint and if cancel is selected just continue to close 
the report?

TIA,
_Bigred


0
_Bigred
9/22/2007 5:02:42 AM
access.reports 4434 articles. 0 followers. Follow

3 Replies
1096 Views

Similar Articles

[PageSpeed] 39

I understand that I have to do this, I actually don't understand HOW to do 
it, and where to put code to accomplish this??

1) What code do I use?
2) Where do I put the code?

Thanks,
_Bigred



"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message 
news:2EC7E384-C82E-459F-841A-49BB994BCBA9@microsoft.com...
> You need to trap for the err 2501 in the code that opens the report.
>
> -- 
> Duane Hookom
> Microsoft Access MVP
>
>
> "_Bigred" wrote:
>
>> I have a report that when it is closed the
>>
>> DoCmd RunCommand acCmdPrint    occurs ... but of course if the user 
>> clicks
>> cancel, it gives me
>>
>> a 2501 error.
>>
>> How & where do I put code to surpress this error. I would just the close
>> even to run the
>> DoCmd RunCommand acCmdPrint and if cancel is selected just continue to 
>> close
>> the report?
>>
>> TIA,
>> _Bigred
>>
>>
>> 


0
_Bigred
9/23/2007 6:18:25 AM
_Bigred wrote:
> I understand that I have to do this, I actually don't understand HOW
> to do it, and where to put code to accomplish this??
>
> 1) What code do I use?
> 2) Where do I put the code?

Answer for 2) first.  You will modify the code you have now so that is WHERE the 
code goes.

Answer for 1)...

(line that starts your event code)

On Error GoTo ErrHandler

(your existing code)

Egress:
Exit Sub

ErrHandler:
Select Case Err.Number
    Case 2501
        'ignore
    Case Else
        MsgBox Err.Description 'for other errors
End Select
Resume Egress

End Sub

In the example above "ErrHandler" and "Egress" are just line labels so you can 
use whatever you want there (those are just the labels I always use).

The idea is that when there are no errors you hit the Exit Sub line so the code 
in the Error Handler is not run.  When there is an error your code will jump 
down to the ErrHandler label and then execute the code it finds there.  The 
Resume line at the end sends the code back up to your code exit point (it is 
better to always have the code terminate at the same spot rather than just 
letting it fall through to your End Sub line).

-- 
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com 


0
Rick
9/23/2007 12:22:09 PM
Thanks much Rick, I'll try that solution out and post back results.

Thank You for your time & help,
_Bigred



"Rick Brandt" <rickbrandt2@hotmail.com> wrote in message 
news:RTsJi.1319$6p6.1211@newssvr25.news.prodigy.net...
> _Bigred wrote:
>> I understand that I have to do this, I actually don't understand HOW
>> to do it, and where to put code to accomplish this??
>>
>> 1) What code do I use?
>> 2) Where do I put the code?
>
> Answer for 2) first.  You will modify the code you have now so that is 
> WHERE the code goes.
>
> Answer for 1)...
>
> (line that starts your event code)
>
> On Error GoTo ErrHandler
>
> (your existing code)
>
> Egress:
> Exit Sub
>
> ErrHandler:
> Select Case Err.Number
>    Case 2501
>        'ignore
>    Case Else
>        MsgBox Err.Description 'for other errors
> End Select
> Resume Egress
>
> End Sub
>
> In the example above "ErrHandler" and "Egress" are just line labels so you 
> can use whatever you want there (those are just the labels I always use).
>
> The idea is that when there are no errors you hit the Exit Sub line so the 
> code in the Error Handler is not run.  When there is an error your code 
> will jump down to the ErrHandler label and then execute the code it finds 
> there.  The Resume line at the end sends the code back up to your code 
> exit point (it is better to always have the code terminate at the same 
> spot rather than just letting it fall through to your End Sub line).
>
> -- 
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
> 


0
_Bigred
9/23/2007 12:54:33 PM
Reply:

Similar Artilces:

How do I print a list of the directory contents
I need to print the disk directory contents. In DOS this was possible. Is it possible in WORD? Thanks No - but you could use the freeware Printfolders utility you can download from my web site that will produce a text listing that you can open in Word. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <...

Redeployment Errors
I am trying to redeploy a CRM 1.2 installation and I keep getting "...cannot grant access to the databases" error during the final step of installation. I'm installing with a user with administrative rights and made sure that user was in SQL with System Admin and DBO rights. Has anyone else experienced this? This can happen if you install CRM by copying files to disk from CD. Try installing from CD and use splash.exe. Also clear Enable LMHOSTS lookup check box in the tcp/ip properties. "Danielle Sturgess" wrote: > I am trying to redeploy a CRM 1.2 install...

printing copies
under print options: Number of copies___. It will only print out 1 copy. I say 5 and it still prints out 1. I am a new user of 2007 Excel I suspect the problem is with the printer. Try getting the newest driver best wishes -- Bernard V Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme remove caps from email "Val in Texas" <Val in Texas@discussions.microsoft.com> wrote in message news:78A83505-189A-4731-AF25-CD5505E33510@microsoft.com... > under print options: Number of copies___. It will only print out 1 copy. > I > say 5 and it still prints out 1. ...

Read Receipt Error
I tried to send a read receipt in response to an e-mail I recieved, but apparently my mail system doesn't support them. Now Outlook (2003) tries to send the receipt every time I do a send/recieve and generates an error message. Unfortunately, I can't find any way to cancel the read receipt, since it doesn't show up in my Outbox or Sent Items folders. I've gone so far as to completely disable sending read receipts, and removing the mail account and recreating it - all to no avail. Anyone have a fix for this? -Kevin ...

Ghosted print and print preview
Hello everyone, I have a problem with printing in excel. The print and print preview options appear ghosted. I still can print through the print icon on the toolbar. Any suggestions??? Martin ...

Print Dynamic Range
I have a basic excel template used for ordering parts. It runs from A1:N250 and I can print easily repeating rows 1:11 on each page (contains job details) . Trouble is sometimes there may only be 10 part numbers requiring only first page and I finish up throwing away trees by printing entire sheet! I know I can reset print area each time am setting this up on Sharepoint for multi users and need a macro/button to recognise number of items and print accordingly. Any help greatly appreciated -- Message posted via http://www.officekb.com Sub SetPrintArea() 'change this cons...

POS Error
We're running POS 1.3r using PCCHARGE. In the past month we have received 3 errors while processing either a sale or a return using a credit card. After scanning the card the register displays the following error message: ERROR 2147217871 TIMEOUT EXPIRED (SOURCE MICROSOFT OLE DB PROVIDER FOR SQL SERVER). It then goes on to say (SQL STATE HYT00 NATIVE ERROR 0) NO HELP FILE AVAILABLE. At this point the transaction exits. I've since discovered that the CUSTOMER's record has not been updated to reflect TOTALVISITS or TOTALSALES. Additionally, TENDERTOTALS, TENDERENTRY, and BAT...

TCP/IP printing
Hello, I have a networking question. I have a print device with a static IP address on one network. A computer on another network can connect to the printer (NBT is enabled and so is LPR) and the drivers are installed but cannot print. I know this is correct behavior but want to know in detail why it seems to half work. I am guessing it has to do with port 138,139 and 515 but not positive. Probably a better question to ask a networking forum but hey. Thanks can you access the printer through the printer IP address? -- ashvin :D Just chill -pls post your feedback on...

different Javascript error after hotfixes installed
Hi all, Have a javascript error that I couldn´t find the answer to on the forums yet. The story: I installed CRM with SQL on one server , DNS is on a different server. All goes well. I can get into CRM as administrator and get the predicted "permission denied error" I install Hot fixes: CRM1.2-KB840934 CRM1.2-KB892949 CRM1.2-KB890599 To remove the "permission denied" error. The permission denied error goes away, but I have a new javescript error that says: Error: Object does not accept this property or method. URL: http://mycrm/_grid/grid_data.aspx?sortCol=ti...

Printing booklet
I am producing a 50 to 60 page booklet using Pubisher 2003. The page format will be using 8.5 x 11 paper folded in half. I need to print both sides of the paper. How do I print the booklet so that I print half the project on one side of the paper and the other half on the back. Will publisher keep track of the pages so that for example; that page 2 and page 50 print on the same side/sheet of paper so when all pages are printed, folded and bound the book reads correctly. Thanks John Houston, Tx more info...I am using a single side printer so I have to run the pages through twice ...

Help with compile error MS S using MT and clr
Help!, I need to compile this code with static libs so it run on another XP machine that does'nt have MS Studio installed. When I compile now I get an ERROR: 1>------ Rebuild All started: Project: drawing_control, Configuration: Release Win32 ------ 1>Deleting intermediate and output files for project 'drawing_control', configuration 'Release|Win32' 1>Compiling... 1>cl : Command line error D8016 : '/MT' and '/clr:oldsyntax' command-line options are incompatible 1>Build log was saved at "file://c:\Documents and Settings\Grant\Desktop\dra...

Check printing in GP 7.0
Dear Guys, I have check payments for vendors, where I'm dealing with LOCAL CURRENCY & FORIGHN CURRENCY. When I paid by check in LOCAL CURRENCY then the amount in words prints perfectly but if i paid by check in FORIGN CURRENCY then the amount in word prints in numeric which i want to print amount in words instead of numbers. Please help me to print checks amount in words for FORIGN CURRENCY as well. Your suggestion would be appricated on above issue thnx Shamin ...

Error Message Required
Hi Product Team, when a user with no role or with a role which has access just to the settings area is trying to load the outlook client, outlook hangs. I believe there should be an error message stating that the user has no required persmissions to access rather than crashing the outlook. also the role which has jsut access to the system settings was customized from an existing role - but still it fails to load. Is this a bug or a feature missing? -- Kamala Ramesh Dynamics CRM Consultant ...

Excel BUG (All Versions) Excel Macro Margins using Print Preview
Where can i post this BUG? (Excel Macro Margins using Print Preview) Is there an Excel BUG reporting site? Steps: 1) New worksheet, write something in it 2) Start recording a new macro 3) File -> Print Preview 4) Click on the Margins Button, the page margins will appear, so that you can visually change and move them 5) Set one or more margins 6) Close the Print Preview 7) Stop the Macro What happened is that in the VBA code there will be writtenthe following lines: ..LeftMargin = Application.InchesToPoints(0.91) ..RightMargin = Application.InchesToPoints() Where in second line ther...

CHtmlView and Printing
Hi Everyone, The CHtmlView is giving me alot of head aches. Here is what I am doing. I am opening an XML file (being formatted using XLST) in a hidden CHtmlView and printing it. Here is how the process goes: 1. I create the XML file on the fly. 2. load the XML file in to CHtmlView. 3. Once loaded I tell it to print the resulting HTML page. 4, I need to delete XML file after the printing is done. (this is the problem). I can't figure out how to find out when the CHtmlView is done printing. CHtmlView::OnFilePrint is asynchronous. And CHtmlView doesn't tell me that it is currently p...

VS 2008 Error List
I've updated a reference in my VS.NET 2008 web project that I know will cause errors (methods no longer supported, etc). The class is used by multiple pages in my project, however when I build or rebuild the project, only the errors on any file(s) are shown in the Error List. If a file with an error is not open it is not listed in the Error List. Is there a setting for this or another way to cause the Error List to show all project errors? "smay" <smay@discussions.microsoft.com> wrote in message news:430005A6-A023-48CD-980B-3991450CDBEF@microsoft.com... ...

"Tiled" print setting.
I just want the page that I designed to print on one page! I can't change the print setting "tiled" and as it is, it's printing on four pages all broken up. It is possible that you have created your document on a paper size that is not supported by your printer. Try changing your paper size to 8 1/2 by 11 and see if the print options are more to your liking. "MissMarple" <MissMarple@discussions.microsoft.com> wrote in message news:A6776BEA-37EE-4645-B389-866A6CDB2D96@microsoft.com... >I just want the page that I designed to print on one ...

runtime error catcher
Hi, I just want to ask a question. With the runtime error catcher that i'v got below, it still shows up empty box when there is no runtime error It works great if there is a runtime error. Here is the code Sub Importfile() On Error GoTo ErrCheck FileIn = Application.GetOpenFilename() slot = FreeFile Open FileIn For Input As slot ... ErrCheck: 'show the description of the error MsgBox Err.Description End Sub is this the right way of catching the error? Thank you very much in advanc -- associate ----------------------------------------------------------------------- associates&#...

error 80048823
I have tried ever thing on the net pertaining to this error message posted by microsoft. I will no longer use live messenger. I opened a yahoo account maybe I'll have better luck. ever since I download the live 09 i have had nothing but problems take this crap and put it where the sun don't shine. vickie ...

Operating fill handle and moving entire cells with keyboard
Is there any way of operating the fill handle or moving entire cells/range of cells with the keyboard rather than using the mouse (drag and drop). Thanks, Tom. Tom Copy or Cut Select range Select top left corner of range. Hold Shift & press End, Arrow down or right. Copy:= Ctrl + C Cut:= Ctl + X Paste Ctl + V To Fill Down or Right Ctrl + D or ctrl + r Use Excel Help and search for keyboard shortcuts for a complete List. Regards Peter >-----Original Message----- >Is there any way of operating the fill handle or moving >entire cells/range of cells with the keyboard rathe...

Problems with printing
Dear all I have an application, which has been working without problems for the last 7 years. The application has some printing capabilities. Now, we have just gotten a new printer (HP Laserjet CM4370), and when I try to print, my application crashes. The app crashes in the print setup dialog even before I press OK. If I select any other printer as default printer, the app doesn't crash. Then I can show the print setup dialog without problems. But then, when I select the CM4370, the app crashes again, even if I do not press OK. Even if I choose to not show the print setup dialog, and j...

Product Key Issue
We have an issue with an RMS product key. We have installed RMS with the product key successfully and then uninstalled it and tried to re-install it. This time round the product key was not accepted. I understand that in normal circumstances, you activate the key by phone. However, in our case the activate by phone option is disabled. We contacted Microsoft and were passed from operator to operator endlessly and without success. Does anyone know the specific number we have to call for activating our key? We are based in Malta ...

Printing--How not to Print Bkground
In my wrksht there is a cell range highlighted with an autofill color. We use this to show the user where to enter the data. Is there anyway to avoid printing this background color. We want to keep the color in the cell range in our wrksht but we dont want it printed. Hi Jeff, have you tried Print preview, Setup, Sheet, Black & white? Gilles "Jeff" <anonymous@discussions.microsoft.com> wrote in message news:001201c3ba81$023b8af0$a301280a@phx.gbl... > In my wrksht there is a cell range highlighted with an > autofill color. We use this to show the user where t...

Printing in Vista
After each document prints another sheet prints which has the filename, directory,title, subject, author, creation date, last saved on, total editing time, last printed on. These are just some of the items that print on this one sheet of paper. Can anyone help me? In your Print dialog, uncheck "Document Properties." On Nov 30, 1:34=A0pm, peppermint patty <peppermint pa...@discussions.microsoft.com> wrote: > After each document prints another sheet prints which has the filename, > directory,title, subject, author, creation date, last saved on, total edi= ti...

How do you customize the 'Print View'?
Ho do you customize the print view of the different type of records? TIA Antony On Apr 24, 5:09 pm, "Antony" <info AT webpc DOT biz> wrote: > Ho do youcustomizetheprintviewof the different type of records? > TIA > Antony You are probably going to need to create a custom SQL Server Report to get what you need. Or you can create a mail merge via MS word and access a CRM Table or View using ODBC. Post what you need exactly and you might get some more specific direction, or possibly someone has what you need already. Scott Moore www.easiintl.com ...