Conversion question

  • Thread starter Thread starter Chubbly Geezer
  • Start date Start date
C

Chubbly Geezer

Now I've done this before but can't remember how.

I want to pass a string into a procedure and then use that string in a Dim
statement.

i.e.

Public Function PrintReports(ByVal strDel As String, ByVal strSQL As String,
ByVal strSelect As String, ByVal ReportName As Object) As Integer

Dim myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument =
ReportName



But I am getting a conversion error in that I cannot convert a string to
this object type.

Any ideas please.?



Chubbly
 
Chubbly said:
Now I've done this before but can't remember how.

I want to pass a string into a procedure and then use that string in a Dim
statement.

i.e.

Public Function PrintReports(ByVal strDel As String, ByVal strSQL As String,
ByVal strSelect As String, ByVal ReportName As Object) As Integer

Dim myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument =
ReportName



But I am getting a conversion error in that I cannot convert a string to
this object type.

Any ideas please.?



Chubbly

You can not convert a string to a ReportDocument. Now in your function
you are passing an object. What type is this object you are passing in.
Where is your Report stored? Is it a file or an embedded resource?

Chris
 
Chris said:
You can not convert a string to a ReportDocument. Now in your function
you are passing an object. What type is this object you are passing in.
Where is your Report stored? Is it a file or an embedded resource?

Chris

I am passing in a string (was initially declared as a string) which equates
to the report name of rhe report that I want to run. i.e. StandardStatement
This relates to StandardStatement.rpt which is a crystal report which has
been created and resides in my VB 2005 app.

I realise that I can not convert a string to a ReportDocument but do not
know how to use the strings value the way I want.

I am trying to execute a line as below:

Dim myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument =
StandardStatement

I previously used

Dim myReport As StandardStatement

but now find I need to pass in the report name.

Thanks

Chubbly
 
Chubbly said:
I am passing in a string (was initially declared as a string) which equates
to the report name of rhe report that I want to run. i.e. StandardStatement
This relates to StandardStatement.rpt which is a crystal report which has
been created and resides in my VB 2005 app.

I realise that I can not convert a string to a ReportDocument but do not
know how to use the strings value the way I want.

I am trying to execute a line as below:

Dim myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument =
StandardStatement

I previously used

Dim myReport As StandardStatement

but now find I need to pass in the report name.

Thanks

Chubbly

If the string is the report name then you are going about this wrong.

There are two ways I know of to load a report.

1. Get it out of an embedded resource
2. Load it from a file

How I do #2 is:

Dim crReportDocument As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()

crReportDocument.Load(ReportName)

Hope this helps
Chris
 
Chris said:
If the string is the report name then you are going about this wrong.

There are two ways I know of to load a report.

1. Get it out of an embedded resource
2. Load it from a file

How I do #2 is:

Dim crReportDocument As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()

crReportDocument.Load(ReportName)

Hope this helps
Chris

That'll load a report from a specific drive location won't it. What I was
hoping to do was just use an instance of the report without loading an
external file/report from another location.
 
Chubbly said:
That'll load a report from a specific drive location won't it. What I was
hoping to do was just use an instance of the report without loading an
external file/report from another location.

You can do it as an embedded resource. Then you load it straight from
inside your dll. There are examples of that around and you can
reference the resouce from a string then.

Chris
 
Back
Top