Solved

Export Soft Copy to local drive Via Crystal Report 7.0

Posted on 2002-07-22
10
404 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…

856 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