p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

crystal_reports thread: Passing text to a RPT file


Message #1 by "Ian Oates" <ian.oates@u...> on Tue, 25 Jun 2002 11:01:27
Hi
I have a VB UI that passes a recordset to a rpt file. I want to pass some 
text as well to the rpt file in the report footer. E.g. 'Date range 
01/May/02 and 31/May/02'. 

The date range will be entered by the user to restrict the report.

How do I do this with VB, what I have so far is

 Set CrxReport = crxApplication.OpenReport(App.Path & "\VisNoLocs.rpt")
 Set rst = objSQL.fnVisitsNoLocations
 
 CrxReport.DiscardSavedData
 CrxReport.Database.SetDataSource rst, 3, 1
 CRViewer1.ReportSource = CrxReport

Thanks in advance
Message #2 by "Wong Tze Lun" <tzelun0502@l...> on Tue, 25 Jun 2002 21:06:52 +0700
Hi Ian 
 You can pass in as a formula to the report or u can utilize the rdc power by using the section and area in your coding

regards
tl wong


____________________________________________________________
Win a first-class trip to New Orleans and vacation Elvis Style!.
Enter NOW!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes/
Message #3 by Tony Cooper <Tony.Cooper@H...> on Tue, 25 Jun 2002 16:14:10 +0100
Hi Ian

I would create a parameter in the rpt file and pass the text to that... You
can display the parameter field in your report footer
here's a snippet....

Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crpParamDef As CRAXDRT.ParameterFieldDefinition

    Set crpParamDefs = myReport.ParameterFields
    
'This code cycles through the ParameterFieldDefinitions collection in the
main report.
    For Each crpParamDef In crpParamDefs
        With crpParamDef
            Select Case .ParameterFieldName
'It finds and sets the appropriate Crystal parameter.
                Case "myparameter"
                    .SetCurrentValue "*"
                Case Else
            End Select
        End With
    Next

    myReport.EnableParameterPrompting = True
    myReport.Database.Verify

HTH

Tony

-----Original Message-----
From: Ian Oates [mailto:ian.oates@u...]
Sent: 25 June 2002 12:01
To: crystal_reports
Subject: [crystal_reports] Passing text to a RPT file


Hi
I have a VB UI that passes a recordset to a rpt file. I want to pass some 
text as well to the rpt file in the report footer. E.g. 'Date range 
01/May/02 and 31/May/02'. 

The date range will be entered by the user to restrict the report.

How do I do this with VB, what I have so far is

 Set CrxReport = crxApplication.OpenReport(App.Path & "\VisNoLocs.rpt")
 Set rst = objSQL.fnVisitsNoLocations
 
 CrxReport.DiscardSavedData
 CrxReport.Database.SetDataSource rst, 3, 1
 CRViewer1.ReportSource = CrxReport

Thanks in advance
Message #4 by "Ian Oates" <ian.oates@u...> on Thu, 27 Jun 2002 12:24:33
> Hi Ian

I would create a parameter in the rpt file and pass the text to that... You
can display the parameter field in your report footer
here's a snippet....

Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crpParamDef As CRAXDRT.ParameterFieldDefinition

    Set crpParamDefs = myReport.ParameterFields
    
'This code cycles through the ParameterFieldDefinitions collection in the
main report.
    For Each crpParamDef In crpParamDefs
        With crpParamDef
            Select Case .ParameterFieldName
'It finds and sets the appropriate Crystal parameter.
                Case "myparameter"
                    .SetCurrentValue "*"
                Case Else
            End Select
        End With
    Next

    myReport.EnableParameterPrompting = True
    myReport.Database.Verify

HTH

Tony


Tony,
Thanks for the reply, this has helped me solve my problem, though the 'for 
each loop' didn't seem to recogized the second parameterField, I therefore 
ended up with this solution

With CrxReport
 .ParameterFields(1).AddCurrentValue _
  "Between dates " & Format(frmReports.dtPOST1, "dd mmm yyyy") _
         & " and " & Format(frmReports.dtPOST2, "dd mmm yyyy")
                
 .ParameterFields(2).AddCurrentValue "Printed at " & gStrBranchName
            
 .EnableParameterPrompting = False
 .Database.SetDataSource rst, 3, 1
End With

Ian



Message #5 by Tony Cooper <Tony.Cooper@H...> on Thu, 27 Jun 2002 12:26:07 +0100
Ian

Glad to have pointed you the a solution direction, at least

Tony

-----Original Message-----
From: Ian Oates [mailto:ian.oates@u...]
Sent: 27 June 2002 13:25
To: crystal_reports
Subject: [crystal_reports] RE: Passing text to a RPT file


> Hi Ian

I would create a parameter in the rpt file and pass the text to that... You
can display the parameter field in your report footer
here's a snippet....

Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions
Dim crpParamDef As CRAXDRT.ParameterFieldDefinition

    Set crpParamDefs = myReport.ParameterFields
    
'This code cycles through the ParameterFieldDefinitions collection in the
main report.
    For Each crpParamDef In crpParamDefs
        With crpParamDef
            Select Case .ParameterFieldName
'It finds and sets the appropriate Crystal parameter.
                Case "myparameter"
                    .SetCurrentValue "*"
                Case Else
            End Select
        End With
    Next

    myReport.EnableParameterPrompting = True
    myReport.Database.Verify

HTH

Tony


Tony,
Thanks for the reply, this has helped me solve my problem, though the 'for 
each loop' didn't seem to recogized the second parameterField, I therefore 
ended up with this solution

With CrxReport
 .ParameterFields(1).AddCurrentValue _
  "Between dates " & Format(frmReports.dtPOST1, "dd mmm yyyy") _
         & " and " & Format(frmReports.dtPOST2, "dd mmm yyyy")
                
 .ParameterFields(2).AddCurrentValue "Printed at " & gStrBranchName
            
 .EnableParameterPrompting = False
 .Database.SetDataSource rst, 3, 1
End With

Ian




  Return to Index