cltuser
11-01-2004, 08:45 AM
Can you pass parameters via your appplication to a .DSR file. without prompting. I know this works using a .RPT file but I can't seem to get it to work with .DSR. Here is my code: Dim Report As CrystalReport1
Dim crxRpt As CRAXDRT.Report
Dim crxTable As CRAXDRT.DatabaseTable
Dim crxParameters As CRAXDRT.ParameterFieldDefinitions
Private Sub Form_Load()
Set crxRpt = New CrystalReport1
PropTitle = FrmUtilities.TxtPropHeading.Text
ClsTitle = FrmUtilities.TxtClsHeading.Text
StClsTitle = FrmUtilities.TxtStClsHeading.Text
RoutTitle = FrmUtilities.TxtRoutHeading.Text
AcctTitle = FrmUtilities.TxtAcctHeading.Text
ResValTitle = FrmUtilities.TxtResValHeading.Text
ComValTitle = FrmUtilities.TxtComValHeading.Text
MapBlkTitle = FrmUtilities.TxtMapBlkHeading.Text
ClientTitleName = FrmUtilities.TxtClientName.Text
Eff_DOV_Date = FrmUtilities.TxtEffDate.Text
If ParmsArray(4) = "1" Then
InspectionWitness = "1"
Else
InspectionWitness = "0"
End If
Set crxParameters = crxRpt.ParameterFields
crxRpt.DiscardSavedData
For Each crxParam In crxParameters
With crxParam
Select Case .ParameterFieldName
Case "LocationTitle"
.ClearCurrentValueAndRange
.AddCurrentValue PropTitle
Case "AcctTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "AcctTitle"
Case "MapBlkTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "MapBlkTitle"
Case "ClsTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "ClsTitle"
Case "StClsTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "StClsTitle"
Case "RoutTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "RoutTitle"
Case "ResValTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "ResValTitle"
Case "ComValTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "ComValTitle"
Case "FirstPart"
.ClearCurrentValueAndRange
.AddCurrentValue "FirstPart"
Case "SecondPart"
.ClearCurrentValueAndRange
.AddCurrentValue "SecondPart"
Case "ReportKey"
.ClearCurrentValueAndRange
.AddCurrentValue "ReportKey"
Case "TypeOfReport"
.ClearCurrentValueAndRange
.AddCurrentValue "TypeOfReport"
Case "ClientTitleName"
.ClearCurrentValueAndRange
.AddCurrentValue "ClientTitleName"
Case "Eff_DOV_Date"
.ClearCurrentValueAndRange
.AddCurrentValue "Eff_DOV_Date"
Case "InspWit"
.ClearCurrentValueAndRange
.AddCurrentValue "InspectionWitness"
End Select
End With
Next
If TypeOfReport = "R" Or TypeOfReport = "C" Then
If ReportKey = "1" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.ACCOUNT_NO} in {?FirstPart} to {?SecondPart})"
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.ACCOUNT_NO} like {?FirstPart})"
End If
ElseIf ReportKey = "2" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.MAP_BLK_LOT} >= {?FirstPart} AND {BASE.MAP_BLK_LOT} <= {?SecondPart})"
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and {BASE.MAP_BLK_LOT} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "3" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.ROUTING_NO} >= {?FirstPart} AND {BASE.ROUTING_NO} <= {?SecondPart}) "
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and {BASE.ROUTING_NO} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "4" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.SORT_PROPERTY_LOC} >= {?FirstPart}) AND ({BASE.SORT_PROPERTY_LOC} <= {?SecondPart})"
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and {BASE.SORT_PROPERTY_LOC} LIKE {?FirstPart}"
End If
End If
Else
If ReportKey = "1" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.ACCOUNT_NO} in {?FirstPart} to {?SecondPart})"
Else
SelctFor = "({BASE.ACCOUNT_NO} like {?FirstPart})"
End If
ElseIf ReportKey = "2" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.MAP_BLK_LOT} >= {?FirstPart} AND {BASE.MAP_BLK_LOT} <= {?SecondPart})"
Else
SelctFor = "{BASE.MAP_BLK_LOT} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "3" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.ROUTING_NO} >= {?FirstPart} AND {BASE.ROUTING_NO} <= {?SecondPart}) "
Else
SelctFor = "({BASE.ROUTING_NO} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "4" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.SORT_PROPERTY_LOC} >= {?FirstPart}) AND ({BASE.SORT_PROPERTY_LOC} <= {?SecondPart})"
Else
SelctFor = "({BASE.SORT_PROPERTY_LOC} LIKE {?FirstPart})"
End If
End If
End If
crxRpt.RecordSelectionFormula = SelctFor
CRViewer1.ReportSource = crxRpt
CRViewer1.ViewReport
Me.Show
Screen.MousePointer = vbDefault
I use the discardsaveddata but it does not return any data to the report as it looks above. If I put the discardsaveddata commaand after assiging the recordselectionformula...I get the correct results. But I'm prompted for my report parmeters. I'm trying to eliminate the need for the prompting box. Is there something I'm missing here??? Is there something unique in the way vb handles passing info to .rpt and .dsr files???
Dim crxRpt As CRAXDRT.Report
Dim crxTable As CRAXDRT.DatabaseTable
Dim crxParameters As CRAXDRT.ParameterFieldDefinitions
Private Sub Form_Load()
Set crxRpt = New CrystalReport1
PropTitle = FrmUtilities.TxtPropHeading.Text
ClsTitle = FrmUtilities.TxtClsHeading.Text
StClsTitle = FrmUtilities.TxtStClsHeading.Text
RoutTitle = FrmUtilities.TxtRoutHeading.Text
AcctTitle = FrmUtilities.TxtAcctHeading.Text
ResValTitle = FrmUtilities.TxtResValHeading.Text
ComValTitle = FrmUtilities.TxtComValHeading.Text
MapBlkTitle = FrmUtilities.TxtMapBlkHeading.Text
ClientTitleName = FrmUtilities.TxtClientName.Text
Eff_DOV_Date = FrmUtilities.TxtEffDate.Text
If ParmsArray(4) = "1" Then
InspectionWitness = "1"
Else
InspectionWitness = "0"
End If
Set crxParameters = crxRpt.ParameterFields
crxRpt.DiscardSavedData
For Each crxParam In crxParameters
With crxParam
Select Case .ParameterFieldName
Case "LocationTitle"
.ClearCurrentValueAndRange
.AddCurrentValue PropTitle
Case "AcctTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "AcctTitle"
Case "MapBlkTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "MapBlkTitle"
Case "ClsTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "ClsTitle"
Case "StClsTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "StClsTitle"
Case "RoutTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "RoutTitle"
Case "ResValTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "ResValTitle"
Case "ComValTitle"
.ClearCurrentValueAndRange
.AddCurrentValue "ComValTitle"
Case "FirstPart"
.ClearCurrentValueAndRange
.AddCurrentValue "FirstPart"
Case "SecondPart"
.ClearCurrentValueAndRange
.AddCurrentValue "SecondPart"
Case "ReportKey"
.ClearCurrentValueAndRange
.AddCurrentValue "ReportKey"
Case "TypeOfReport"
.ClearCurrentValueAndRange
.AddCurrentValue "TypeOfReport"
Case "ClientTitleName"
.ClearCurrentValueAndRange
.AddCurrentValue "ClientTitleName"
Case "Eff_DOV_Date"
.ClearCurrentValueAndRange
.AddCurrentValue "Eff_DOV_Date"
Case "InspWit"
.ClearCurrentValueAndRange
.AddCurrentValue "InspectionWitness"
End Select
End With
Next
If TypeOfReport = "R" Or TypeOfReport = "C" Then
If ReportKey = "1" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.ACCOUNT_NO} in {?FirstPart} to {?SecondPart})"
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.ACCOUNT_NO} like {?FirstPart})"
End If
ElseIf ReportKey = "2" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.MAP_BLK_LOT} >= {?FirstPart} AND {BASE.MAP_BLK_LOT} <= {?SecondPart})"
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and {BASE.MAP_BLK_LOT} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "3" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.ROUTING_NO} >= {?FirstPart} AND {BASE.ROUTING_NO} <= {?SecondPart}) "
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and {BASE.ROUTING_NO} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "4" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and ({BASE.SORT_PROPERTY_LOC} >= {?FirstPart}) AND ({BASE.SORT_PROPERTY_LOC} <= {?SecondPart})"
Else
SelctFor = "({BASE.LCI} = {?TypeOfReport}) and {BASE.SORT_PROPERTY_LOC} LIKE {?FirstPart}"
End If
End If
Else
If ReportKey = "1" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.ACCOUNT_NO} in {?FirstPart} to {?SecondPart})"
Else
SelctFor = "({BASE.ACCOUNT_NO} like {?FirstPart})"
End If
ElseIf ReportKey = "2" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.MAP_BLK_LOT} >= {?FirstPart} AND {BASE.MAP_BLK_LOT} <= {?SecondPart})"
Else
SelctFor = "{BASE.MAP_BLK_LOT} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "3" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.ROUTING_NO} >= {?FirstPart} AND {BASE.ROUTING_NO} <= {?SecondPart}) "
Else
SelctFor = "({BASE.ROUTING_NO} LIKE {?FirstPart}"
End If
ElseIf ReportKey = "4" Then
If FirstPart <> SecondPart Then
SelctFor = "({BASE.SORT_PROPERTY_LOC} >= {?FirstPart}) AND ({BASE.SORT_PROPERTY_LOC} <= {?SecondPart})"
Else
SelctFor = "({BASE.SORT_PROPERTY_LOC} LIKE {?FirstPart})"
End If
End If
End If
crxRpt.RecordSelectionFormula = SelctFor
CRViewer1.ReportSource = crxRpt
CRViewer1.ViewReport
Me.Show
Screen.MousePointer = vbDefault
I use the discardsaveddata but it does not return any data to the report as it looks above. If I put the discardsaveddata commaand after assiging the recordselectionformula...I get the correct results. But I'm prompted for my report parmeters. I'm trying to eliminate the need for the prompting box. Is there something I'm missing here??? Is there something unique in the way vb handles passing info to .rpt and .dsr files???