?
Solved

Export Soft Copy to local drive Via Crystal Report 7.0

Posted on 2002-07-22
10
Medium Priority
?
423 Views
Last Modified: 2007-12-19
I'm using VB 5.0, Crystal Report 7.0, running on Win 2K.
My Database is SQL 6.5.

Here, I have a ready made report at my c:\ called MyRpt.rpt

I'd wish to export the report to another format thru my VB 5.0. Anybody can illustrate me the steps?

With CrystalReport1
  .ReportFileName = "c:\MyRpt.rpt"
  .ReplaceSelectionFormula "{view_rpt_My_Report.id} = 4094"
  .Destination = crptToFile
  .PrintFileType = crptText
  .PrintFileName = "MyFile.txt"
  .PrintReport
End With

I've got the error msg -> "can't open SQL Server"

Pls help.. how to overcome this? Where shall I supply my Database connection, etc?

thanks.
0
Comment
Question by:my8817
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
10 Comments
 

Author Comment

by:my8817
ID: 7170884
the error msg was together with this
Run-Time error '20599'.

pls help.. quite urgent.
0
 

Author Comment

by:my8817
ID: 7170900
left out some lines of code.

With CrystalReport1
 .LogOnServer "p2smon.dll", "DBSvr", "MyDb", "SA", "Pswd"
 .ReportFileName = "c:\MyRpt.rpt"
 .ReplaceSelectionFormula "{view_rpt_My_Report.id} = 4094"
 .Destination = crptToFile
 .PrintFileType = crptText
 .PrintFileName = "MyFile.txt"
 .Action = 1
 .PrintReport
End With

0
 

Author Comment

by:my8817
ID: 7171309
rite now, another error encountered.

-----------------------------------------------------------
Run-Time error '20515'

Error in formula <Record_Selection>.
'{tblA.EffectiveDt} in {tblB.EffetiveDt} to {tblB.CeaseDt} and'

This field name is not known.

-----------------------------------------------------------

pls help.. thanks.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 101

Expert Comment

by:mlmcc
ID: 7171921
Looks like there is more to the selection formula but as a guess if what you gave is accurate

'{tblA.EffectiveDt} in {tblB.EffetiveDt} to {tblB.CeaseDt} and'

should be (missing c in the second tblB.EffectiveDt)

'{tblA.EffectiveDt} in {tblB.EffectiveDt} to {tblB.CeaseDt} and'

mlmcc
0
 

Author Comment

by:my8817
ID: 7173209
ok, here's the senario. I have an existing report which I can use the Crystal Report designer to call to DB without any problem by supplying only 1 parameter.

in that case, do I still need to pass more than 1 parameter to the VB App?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 7175948
No you shouldn't need more than 1.

mlmcc
0
 

Author Comment

by:my8817
ID: 7176100
mlmcc,

ok, I've no idea how to proceed with this. Can u pls just supply me the complete coding for VB to export my existing report to another format?

Just drop all my code above. Thanks.
0
 

Author Comment

by:my8817
ID: 7176574
paste my latest code here.

Dim cr_Export_App As New CRPEAuto.Application
Dim cr_Export_Rpt As CRPEAuto.Report

With cr_Export_App
     .LogOnServer "p2smon.dll", "UsrDSN", "MyDB", _
                  "sa", "pswd"
     Set cr_Export_Rpt = .OpenReport("c:\MyRpt.rpt", crOpenReportByTempCopy)

End With

With cr_Export_Rpt

    .ReadRecords
    .ExportOptions.FormatType = crEFTText
    .ExportOptions.DestinationType = crEDTDiskFile
    .ExportOptions.DiskFileName = "c:\Test.txt"
    .ReplaceSelectionFormula "{prmProcessNo} = 4094"
    .Export False
End With

I encountered the error at the .ReadRecords
says

Run-Time error '20599'
can't open SQL Server

Pls help me to verify it, ok?

I've checked on my System DSN, it's definitely there.
Btw, is my coding syntax & the logic flow correct?
0
 
LVL 5

Accepted Solution

by:
ianouii earned 1000 total points
ID: 7179510
'Place a Crystal Report control on your form by choosing
'from the component on the toolbox.

'Put this code in.

Screen.MousePointer = vbHourglass

With CrystalReport1
  .Connect = "DSN=UsrDSN; UID=sa; PWD=pswd"
  .ReportFileName = "c:\MyRpt.rpt"
  .ParameterFields(0) = "prmProcessNo;4094;TRUE"
  .Destination = crptToFile
  .PrintFileType = crptText
  .PrintFileName = "c:\Test.txt"
  .Action = 1
End With

Screen.MousePointer = vbDefault

'Define your DSN nicely then to ensure your db connection is hassle free.
0
 

Author Comment

by:my8817
ID: 7179561
Thanks! This really solved my problem.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

801 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