How to Capture Cancel on Crystal Parameter Dialog Box

I am Using VB 6.0 code with Crystal Reports 8.
My problem is that I have set in the Cruystal report some parameters (starting date, ending date etc...)

When I run the report through VB and try to cancel the
Report by clicking the cancel button  I still get the report running!
How can I capture this cancel & stop the report in its tracks ?

Who is Participating?
I've tried to use their cancel button and it never seems to work.  So, I think that there is an option you can set that will keep their cancel button from appearing.

The only thing that I've gotten to work, is that I put my crystal report control on a special non-modal form, and when I go to run the report, I'll load the form and run the report (if you're not doing print-preview, you don't have to show the form, just load it, if you are doing print-priview, you can attach the Crystal preview window to that form, so that you have more control over the Crystal preview window).  If the user wants to cancel, they would click a button on the form that they used to invoke the report, and all it does is unload the form with the Crystal Report control on it and set the form = nothing.  Doing this flushes Crystal from memory, and hopefully will stop your report from running.
Are you refering to the CANCEL button on the print setup form from VB?  If so there is no way to capture the cancel click.  Once you activate the report from VB it will run to completion.

To avoid this I built my own Print Setup form and then have full control over the CANCEL button.

If this is what you want I'll be happy to post the code for the form and the calling routines.

good luck
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Jules_MadgwickAuthor Commented:
Yes, I am trying to cancel thee print from Crystals own dialogue box.  Whether I enter my parameters in or not as soon as I hit cancel the report tries to run.
I still want the Crystal Dialogue box!  but if the only way to cancel a print is to have my own Print & Parameter Setup then yes  would appreciate your code. Thank you
Hi Jules_Madgwick,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept mdougan's comment(s) as an answer.

Jules_Madgwick, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer
Do you still need the code?

per recommendation

Community Support Moderator @Experts Exchange
Hey jules,

I too had this problem for awhile, but recently figured it out.  I'm not sure if it'll work for all versions of Crystal, but it's worth a try.

Apparently, the .PrinterName property of the Crystal Report Control is set as a Null string by default and can only be set by code, or when the user hits "Ok", not "Cancel" on the .PrinterSelect popup box!!!


    If crReport.PrinterName <> "" Then
        crReport.PrinterName = ""  'back to default
    End If

works like a charm!!!

Don't for get to set the PrinterName back to "" as if a user prints and then choose cancel the next time, the PrinterName will still be the printer selected from the prior print action.

Who thought making the Crystal Report Control work that way was a good idea????

Jules_MadgwickAuthor Commented:
Ok not quite what I'm looking for.
On the Parameter dialogue there is a cancel button this is the one I would like work.
I have the same Problem, I want to cancel the report during the Parameter dialogue is shown, but nothing happens when I click the cancel button - has anyone a solution for this problem??
Look at

You may have to join the group.  Look in Documents then Expert Exchange files

The way I use it is to display the form modal then when the user clicks Cancel or Print I hide the form and then can use the informatiion entered from the CRViewer.

If you need more help let me know and I'll post the code from one of my printing routines.

Jules_MadgwickAuthor Commented:
This Code from Presbria work well but only if you want to see the windows Printer Setup GUI.
Still is not the right solution as far as I'm concerned but can get you out of a tricky situation.

   If CrystalReport1.PrinterName <> "" Then
       CrystalReport1.PrinterName = ""  'back to default
   End If

put this code in instead of your CrystalReport1.Action = 1
Jules_MadgwickAuthor Commented:
Presbria I should have awarded you points - Sorry
Does anyone know how to do this in Visual Foxpro?
I've tried to guess at the code change but go zilch

tmcconn: I see you are a new user.  It is customary to ask your own questions.  On the left side there is a link Ask A Question.  Click it and you will be able to ask a question.

According to Crystal you cannot capture the click of the CANCEL from the Crystal Printer Select after clicking the print button.  The report will click.


Thanks mimcc,

Yeah, I figured that out and posted my own question

Thanks to CarlWaner I got what I needed. I included the final solution so check it out for reference.

Thanks again,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.