[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Export Soft Copy to local drive Via Crystal Report 7.0

Posted on 2002-07-22
10
Medium Priority
?
432 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

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.
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…
Suggested Courses

650 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