Solved

How to save crystal report result in VB App?

Posted on 2002-07-01
9
187 Views
Last Modified: 2010-05-02
Hi,

I have a vb app that uses crystal report 8.0 to display database data in "table report" and images(*.bmp) files in "image report". I can print them but how can I save them into a file. Is there anyway I can save the table report as a word doc and the image report as any image file? I've seen something like the following with Crystal report 8.5:
 crystalReport1.PrintFileName = "C:tmp\myReport.??"

I am not sure if that is the way crystal report 8.5 save to file. But I can't even find the ".PrintFileName" function in 8.0. Can anyone help? Thanks in advance!

0
Comment
Question by:ahpui
9 Comments
 

Expert Comment

by:Allas
ID: 7122886
Hello
I can answer a part about saving Crystal report as a file (not sure about image file). You'll need to change settings of Crystal control properties (in VB project) destination to "To File" in general properties, then in PrintToFile properties - choose file format. Then write a code to give a path to the control, give it a title and so on. In my example I used RTF file.
CrRepExp.ReportFileName = App.Path & "\CoverPage.rpt"
CrRepExp.SelectionFormula = strSelect
CrRepExp.DiscardSavedData = True
Screen.MousePointer = vbHourglass
CrRepExp.PrintFileName = "file path\cov" & Dtm & ".rtf"
CrRepExp.PrintReport
To save graphics you might need to use different file format. About image file - it doesn't have default settings for any. Try to experiment with different formats.
Hope that helps.
0
 

Author Comment

by:ahpui
ID: 7123007
hi Allas,

in my vb app, I added crystal report as designer and  linked the designer to a database and create table with some of the database data fields. Then I use CRViewer control to show the resulting table as a report. My problem is I don't know how to save what I see from the CRViewer (the report) to a word doc or, if it's an image display, to an image file. Does my approach in creating the report conflict with what you proposed? if it does, is there other ways to create the report? How do I change the setting of the crystal control? I can't find the "PrintToFile" property.
0
 

Expert Comment

by:Allas
ID: 7123088
I used Crystal Report as control to call existing Crystal Report from VB. To get to the properties - put CR control on the form, right click your mouse and choose properties. In my case I was creating Crystal Report based on queries/tables from Access database and in VB I was attaching report to the control and in the code - set up report name, title, selection criteria and so on. This sample I sent you in previous answer works just fine but like I said you will loose some graphics when printing to file. PrintToFile is setting for Crystal Report control, not the viewer. I never tried CRViewer myself - not sure how do it this way. Alla
0
 

Author Comment

by:ahpui
ID: 7123163
hi Alla,

can you give me an example on creating report using CR control. Any links for sample code? Thanks!

ahpui
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Accepted Solution

by:
Allas earned 200 total points
ID: 7124459
Good morning
To create report - open Crystal Report software. You can create report using report expert or from scratch. Through wizard it's pretty self explanatory. There is an option there to choose tables/queries from database as a base for the report. It'll build auto-report for you and then you can modify it. Save it.
In VB - put Crystal Report control on your form. Name control (in my example it's CrRepDebts). You could setup all properties by right clicking the mouse and choosing necessary options or set it up in the code - I prefer the code - gives you more flexibility (like setting date range for ex.). Put a commandButton control on the form and attach following code (modify it first) on Click event for this button. Sample of the code is:

strSelect = "{QryCensusDate_1A.FacCode}= '" & strFacil & "' and {QryCensusDate_1A.Date} in #" & mtStart & "# to #" & mtEnd & "# "
CrRepDebts.ReportFileName = App.Path & "\Sec1AMonthCens.rpt"
CrRepDebts.SelectionFormula = strSelect
CrRepDebts.DiscardSavedData = True
CrRepDebts.ReportTitle = "Section I.A. - Monthly Census for " & facName & "  for " & Format(mtEnd, "mmmm") & " - " & Year(mtEnd) & ""
Screen.MousePointer = vbHourglass
CrRepDebts.PrintReport
Screen.MousePointer = vbDefault

In this sample I filter table records to get specified by user month only and give it custom title. The end result is printing the report. You could setup CrystalReport control to print preview, print to printer, print to file.
To print to file - see sample in my first answer. Of course don't forget to substitute your report name and you might not need selection fomula.
Good Luck
Alla
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 7134002
learning
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7522831
Dear Allas
I've rejected your proposed answer as Experts Exchange holds an experiment to work without the answer button.

See: <http://www.experts-exchange.com/jsp/communityNews.jsp>
Paragraph: Site Update for Wednesday, November 06, 2002

By this rejection the Asker will be notified by mail and hopefully he will take his responsibility to finalize the question or post an additional comment.
The Asker sees a button beside every post which says "Accept This Comment As Answer" (including rejected answers) -- so if he/she thinks yours is the best, you'll be awarded the points and the grade.

EXPERTS: I will return in seven days to close this question.
Please leave your thoughts and recommendations here

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Thanks !

kodiakbear
Experts Exchange Moderator
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7970994
Hi ahpui,
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 Allas's comment(s) as an answer.

ahpui, 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
 

Expert Comment

by:SpideyMod
ID: 8018639
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

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 While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

19 Experts available now in Live!

Get 1:1 Help Now