By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,887 Members | 1,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,887 IT Pros & Developers. It's quick & easy.

Conversion question

P: n/a
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.ReportDocum ent =
ReportName

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

Any ideas please.?

Chubbly
Feb 9 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Chubbly Geezer wrote:
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.ReportDocum ent =
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
Feb 9 '06 #2

P: n/a

"Chris" <no@spam.com> wrote in message
news:Ow*************@TK2MSFTNGP14.phx.gbl...
Chubbly Geezer wrote:
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.ReportDocum ent =
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


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.ReportDocum ent =
StandardStatement

I previously used

Dim myReport As StandardStatement

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

Thanks

Chubbly
Feb 9 '06 #3

P: n/a
Chubbly Geezer wrote:
"Chris" <no@spam.com> wrote in message
news:Ow*************@TK2MSFTNGP14.phx.gbl...
Chubbly Geezer wrote:
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.ReportDocum ent =
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

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.ReportDocum ent =
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.ReportDocum ent()

crReportDocument.Load(ReportName)

Hope this helps
Chris
Feb 9 '06 #4

P: n/a

"Chris" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Chubbly Geezer wrote:
"Chris" <no@spam.com> wrote in message
news:Ow*************@TK2MSFTNGP14.phx.gbl...
Chubbly Geezer wrote:

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.ReportDocum ent =
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

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.ReportDocum ent =
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.ReportDocum ent()

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.
Feb 9 '06 #5

P: n/a
Chubbly Geezer wrote:
"Chris" <no@spam.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Chubbly Geezer wrote:
"Chris" <no@spam.com> wrote in message
news:Ow*************@TK2MSFTNGP14.phx.gbl...
Chubbly Geezer wrote:
>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.ReportDocum ent =
>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
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.ReportDocum ent =
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.ReportDoc ument()

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.


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
Feb 9 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.