|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Conversion questionI 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 Geezer wrote:
Show quoteHide quote > Now I've done this before but can't remember how. You can not convert a string to a ReportDocument. Now in your function > > 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 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
Show quote
Hide quote
"Chris" <no@spam.com> wrote in message I am passing in a string (was initially declared as a string) which equates 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 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 Geezer wrote:
Show quoteHide quote > "Chris" <no@spam.com> wrote in message If the string is the report name then you are going about this wrong.> 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 > > 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
Show quote
Hide quote
"Chris" <no@spam.com> wrote in message That'll load a report from a specific drive location won't it. What I was 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 hoping to do was just use an instance of the report without loading an external file/report from another location. Chubbly Geezer wrote:
Show quoteHide quote > "Chris" <no@spam.com> wrote in message You can do it as an embedded resource. Then you load it straight from > 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. > > inside your dll. There are examples of that around and you can reference the resouce from a string then. Chris |
|||||||||||||||||||||||