Solved

How to Capture Cancel on Crystal Parameter Dialog Box

Posted on 2002-04-19
16
897 Views
Last Modified: 2008-05-09
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 ?

jules
0
Comment
Question by:Jules_Madgwick
  • 5
  • 4
  • 2
  • +5
16 Comments
 
LVL 18

Accepted Solution

by:
mdougan earned 50 total points
Comment Utility
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.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
listening
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
mlmcc
0
 

Author Comment

by:Jules_Madgwick
Comment Utility
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
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Do you still need the code?

mlmcc
0
 

Expert Comment

by:SpideyMod
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0
 

Expert Comment

by:presbria
Comment Utility
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!!!

So,

    crReport.PrinterSelect
    If crReport.PrinterName <> "" Then
        crReport.PrintReport
        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????

Brian
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Jules_Madgwick
Comment Utility
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.
0
 

Expert Comment

by:Nele77
Comment Utility
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??
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Look at


http://groups.msn.com/McCrackenUNO

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.

mlmcc
0
 

Author Comment

by:Jules_Madgwick
Comment Utility
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.

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

put this code in instead of your CrystalReport1.Action = 1
0
 

Author Comment

by:Jules_Madgwick
Comment Utility
Presbria I should have awarded you points - Sorry
0
 

Expert Comment

by:tmcconn
Comment Utility
Does anyone know how to do this in Visual Foxpro?
I've tried to guess at the code change but go zilch

Thanks,
T
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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.

mlmcc


0
 

Expert Comment

by:tmcconn
Comment Utility
Thanks mimcc,

Yeah, I figured that out and posted my own question   http://www.experts-exchange.com/Databases/FoxPro/Q_21207443.html#12589355

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

Thanks again,
Troy
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now