Home All Groups Group Topic Archive Search About
Author
9 Feb 2006 12:04 PM
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

Author
9 Feb 2006 2:09 PM
Chris
Chubbly Geezer wrote:
Show quoteHide quote
> 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
Author
9 Feb 2006 3:24 PM
Chubbly Geezer
Show quote Hide quote
"Chris" <no@spam.com> wrote in message
news:OwLAOJYLGHA.720@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.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

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
Author
9 Feb 2006 5:16 PM
Chris
Chubbly Geezer wrote:
Show quoteHide quote
> "Chris" <no@spam.com> wrote in message
> news:OwLAOJYLGHA.720@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.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
>
>
> 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
Author
9 Feb 2006 5:37 PM
Chubbly Geezer
Show quote Hide quote
"Chris" <no@spam.com> wrote in message
news:%23q27ByZLGHA.2696@TK2MSFTNGP14.phx.gbl...
> Chubbly Geezer wrote:
>> "Chris" <no@spam.com> wrote in message
>> news:OwLAOJYLGHA.720@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.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
>>
>>
>> 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

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.
Author
9 Feb 2006 7:52 PM
Chris
Chubbly Geezer wrote:
Show quoteHide quote
> "Chris" <no@spam.com> wrote in message
> news:%23q27ByZLGHA.2696@TK2MSFTNGP14.phx.gbl...
>
>>Chubbly Geezer wrote:
>>
>>>"Chris" <no@spam.com> wrote in message
>>>news:OwLAOJYLGHA.720@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.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
>>>
>>>
>>>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
>
>
> 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