[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Export Soft Copy to local drive Via Crystal Report 7.0

Posted on 2002-07-22
10
Medium Priority
?
437 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

829 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