Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports

Status
Not open for further replies.

MikeMcKeown

Programmer
Apr 1, 2003
69
GB
Hi,

I have been working on the piece of code below in a DTS package. The two lines highlighted are causing problems. The 1st one I am getting an error with is saying that their is a type mismatch. In the table currentpractice is a varchar - am I declaring it incorrectly?

The second line says that there is a missing or out of date export dll.

Any ideas? I have this code working in normal visual basic.






Function Main()

Main = DTSTaskExecResult_Success

Dim Conn 'ADO Connection
Dim Comm 'ADO Command
Dim Rcdset 'ADO Recordset

Dim App
Dim report 'Crystal Report
Dim DB 'Crystal Database
Dim Tables 'Crystal DatabaseTables
Dim Table1 'Crystal DatabaseTable
Dim currentpractice
currentpractice = 2A

Dim final

Set Conn = CreateObject("ADODB.Connection")
Set Comm = CreateObject("ADODB.Command")
Set Rcdset = CreateObject("ADODB.Recordset")

Conn.Open "Provider=SQLOLEDB.1;Initial Catalog=E_Audit_Database;App=Crystal Export;Data Source=(local)", "**", "*****"
'Comm.ActiveConnection = Conn

final = "final_reports_last_generated"

Rcdset.Open final, Conn, adOpenStatic, , adCmdTable


While (NOT Rcdset.EOF )

Msgbox("in the While statement")


currentpractice = Rcdset.Fields.Item(0)

Msgbox(currentpractice)

Set App = CreateObject("CrystalRuntime.application.8.5") ' This is on a machine with Crystal 8.5
Set report = App.OpenReport("Z:\report1.rpt")

report.DiscardSavedData

Set DB = report.Database

Set Tables = DB.Tables
Set Table1 = Tables.Item(1)


report.ParameterFields.Item(1).AddCurrentValue currentpractice



report.ReadRecords

report.ExportOptions.DestinationType = crEDTDiskFile
report.ExportOptions.FormatType = crEFTWordForWindows
report.ExportOptions.DiskFileName = "C:\TEST\diditwork.rtf"

'report.Export False

Set Table1 = Nothing
Set Tables = Nothing
Set DB = Nothing
Set report = Nothing
Set App = Nothing
Set parameter = Nothing
Set CRXPFDs = Nothing
Set CRXPFD = Nothing

Rcdset.MoveNext

Wend

Main = DTSTaskExecResult_Success
End Function
 
I have managed to fix the 1st problem, I was just missing ().

The second one is confusing me - I have it working in visual basic 6 module. However when I transfer it to the activeX module I receive the error.

Do I have to install anything?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top