Solved

Export Soft Copy to local drive Via Crystal Report 7.0

Posted on 2002-07-22
10
390 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
  • 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
 
LVL 100

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 100

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 250 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

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 I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

16 Experts available now in Live!

Get 1:1 Help Now