Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing multiple parameters to cr9 reports

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
0
0
US
I have a vb app that has at least 100 different reports which is in crystal reports 9.
The code I have works most of the time but from time to time the parameters don't match up. Since the reports have different parameters that they need, i need to find a way to pass the correct parameter to each report without having to have a line for each report.

Currently the code is:
Code:
   Select Case g_rptName  'path and name of report
       'PRODUCTION
       Case "\\cob-appp-01\data\cms compiled programs\reports\cr9.0reports\miscreports\DSPOutstandingConditionsChkLst.rpt"
                  crReport.ParameterFields.GetItemByName("Job Number").AddCurrentValue (g_ProjectNumber)
                   crReport.ParameterFields.GetItemByName("FeeType").AddCurrentValue ("17")
                   
       Case "\\cob-appp-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms402.rpt"
                crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
                crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dspDscRespId)

       Case "\\cob-appp-01\data\cms compiled programs\reports\cr9.0reports\miscreports\cms333new.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)

        Case "\\cob-appp-01\data\dsg\DSGReports\CMS501.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
        
        Case "\\cob-appp-01\data\dsg\DSGReports\CMS500.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
                  
         Case "\\cob-appp-01\data\dsg\DSGReports\CMS502.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
                  
          Case "\\cob-appp-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms404.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
       'Test (Dev)
       Case "\\cob-appd-01\data\cms compiled programs\reports\cr9.0reports\miscreports\DSPOutstandingConditionsChkLst.rpt"
                  crReport.ParameterFields.GetItemByName("Job Number").AddCurrentValue (g_ProjectNumber)
                   crReport.ParameterFields.GetItemByName("FeeType").AddCurrentValue ("17")

       Case "\\cob-appd-01\data\cms compiled programs\reports\cr9.0reports\miscreports\cms333new.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)

       Case "\\cob-appd-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms402.rpt"
                crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
                crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dspDscRespId)
            
       Case "\\cob-appd-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms406.rpt"
                 crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dscRejectMainId)
                'crReport.ParameterFields.GetItemByName("").AddCurrentValue (g_dspDscRespId)
                Debug.Print g_dscRejectMainId
       Case "\\cob-appd-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms407.rpt"
                 crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dscRejectMainId)
                'crReport.ParameterFields.GetItemByName("").AddCurrentValue (g_dspDscRespId)

        'QA
       Case "\\cob-appq-01\data\cms compiled programs\reports\cr9.0reports\miscreports\DSPOutstandingConditionsChkLst.rpt"
                  crReport.ParameterFields.GetItemByName("Job Number").AddCurrentValue (g_ProjectNumber)
                   crReport.ParameterFields.GetItemByName("FeeType").AddCurrentValue ("17")

       Case "\\cob-appq-01\data\cms compiled programs\reports\cr9.0reports\miscreports\cms333new.rpt"
                  crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)

       Case "\\cob-appq-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms402.rpt"
                crReport.ParameterFields.GetItemByName("Project Number").AddCurrentValue (g_ProjectNumber)
                crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dspDscRespId)
            
       Case "\\cob-appq-01\data\cms compiled programs\reports\cr9.0reports\DSGReports\cms406.rpt"
                 crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dscRejectMainId)
                 
       Case "\\cob-appQ-01\data\cms compiled programs\reports\cr90.reports\DSGReports\cms407.rpt"
                 crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dscRejectMainId)
                'crReport.ParameterFields.GetItemByName("").AddCurrentValue (g_dspDscRespId)
 
       Case Else
      ' Debug.Print g_rptName
    '  11/23/10 ljh added if because it kept falling out of casse stmt on this one report
                 'crReport.ParameterFields.GetItemByName("Job Number").AddCurrentValue (g_ProjectNumber)
                 
                 If Right(g_rptName, 10) = "cms407.rpt" Then
                ' Debug.Print Right(g_rptName, 7)
                 crReport.ParameterFields.GetItemByName("ResponseID").AddCurrentValue (g_dscRejectMainId)
                 Else
                 Debug.Print g_ProjectNumber
                 Debug.Print Err.Number
                 
                 crReport.ParameterFields.GetItemByName("ResponseID").AddCurrentValue (g_dscRejectMainId)
                   
                 End If
                ' crReport.ParameterFields.GetItemByName("ResponseId").AddCurrentValue (g_dspdscrespid)
                
                 
    End Select

While we tried to keep the same parameters to be consistent, this wasn't always the case.
My work around is to add the report to the list (due to time constraints) but I would really rather have clean code.
If the report doesn't have one id, I need it to check for the next id so it won't fail.
Thanks lhuffst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top