qwertyqwerty
Programmer
Hi,
I am trying to use parameters in CR to build a report. I have a select join statement and need to show on the report 5 fields that follow the select bit in the sql statement. I have tried a number of things but can't seem to see how to solve this.
On my report inside the VB IDE, I have the 5 fields laid out as parameters. I have no formula fields and when I click Select expert over one of those parameter fields I get just a dialog box with a greyed out OK button.
Heres the code I have so far. Believe it is all wrong because errors show up when the form is trying to show the CRViewer. Any help on this would be breatly appreciated.
Regards,
Davos.
------------------
Set AdoRSCustSum = New ADODB.Recordset
Set frmDet = New CrystRep2Form
strSql = "SELECT C.CustomNber, CB.PaymDate, CB.PaymRef, CB.PaymNotes, " & _
"CB.PaymAmnt FROM CustomerBilling As CB INNER JOIN Customers As C ON " & _
"CB.CustID = C.CustID WHERE PaymDate >= #" & FormatDate(Format(dateSlsh1, "mm/dd/yyyy")) & _
"#" & " AND PaymDate <= #" & FormatDate(Format(dateSlsh2, "mm/dd/yyyy")) & "#"
'debug.print strSql
AdoRSCustSum.Open strSql, myDbCon, adOpenKeyset, adLockOptimistic
Do Until AdoRSCustSum.EOF
With CustSumm
.DiscardSavedData
.EnableParameterPrompting = False
If Not IsNull(AdoRSCustSum![CustomNber]) = True Then
.ParameterFields.GetItemByName("CustID").AddCurrentValue CStr(AdoRSCustSum![CustomNber])
End If
If Not IsNull(AdoRSCustSum![PaymDate]) = True Then
.ParameterFields.GetItemByName("PaymDate").AddCurrentValue CStr(AdoRSCustSum![PaymDate])
End If
If Not IsNull(AdoRSCustSum![PaymRef]) = True Then
.ParameterFields.GetItemByName("PaymRef").AddCurrentValue CStr(AdoRSCustSum![PaymRef])
End If
If Not IsNull(AdoRSCustSum![PaymNotes]) = True Then
.ParameterFields.GetItemByName("PaymNotes").AddCurrentValue CStr(AdoRSCustSum![PaymNotes])
End If
If Not IsNull(AdoRSCustSum![PaymAmnt]) = True Then
.ParameterFields.GetItemByName("PaymAmnt").AddCurrentValue CStr(AdoRSCustSum![PaymAmnt])
End If
End With
If AdoRSCustSum.EOF = False Then
AdoRSCustSum.MoveNext ' Move to next record
End If
Loop
AdoRSCustSum.Close
Set AdoRSCustSum = Nothing
With frmDet
loadMe = True
.CRViewer91.ReportSource = CustSumm
frmDet.CRViewer91.ViewReport
Call WaitTimer(3)
frmDet.CRViewer91.Refresh
frmDet.Show
End With
Set CustSumm = Nothing
Set frmDet = Nothing
I am trying to use parameters in CR to build a report. I have a select join statement and need to show on the report 5 fields that follow the select bit in the sql statement. I have tried a number of things but can't seem to see how to solve this.
On my report inside the VB IDE, I have the 5 fields laid out as parameters. I have no formula fields and when I click Select expert over one of those parameter fields I get just a dialog box with a greyed out OK button.
Heres the code I have so far. Believe it is all wrong because errors show up when the form is trying to show the CRViewer. Any help on this would be breatly appreciated.
Regards,
Davos.
------------------
Set AdoRSCustSum = New ADODB.Recordset
Set frmDet = New CrystRep2Form
strSql = "SELECT C.CustomNber, CB.PaymDate, CB.PaymRef, CB.PaymNotes, " & _
"CB.PaymAmnt FROM CustomerBilling As CB INNER JOIN Customers As C ON " & _
"CB.CustID = C.CustID WHERE PaymDate >= #" & FormatDate(Format(dateSlsh1, "mm/dd/yyyy")) & _
"#" & " AND PaymDate <= #" & FormatDate(Format(dateSlsh2, "mm/dd/yyyy")) & "#"
'debug.print strSql
AdoRSCustSum.Open strSql, myDbCon, adOpenKeyset, adLockOptimistic
Do Until AdoRSCustSum.EOF
With CustSumm
.DiscardSavedData
.EnableParameterPrompting = False
If Not IsNull(AdoRSCustSum![CustomNber]) = True Then
.ParameterFields.GetItemByName("CustID").AddCurrentValue CStr(AdoRSCustSum![CustomNber])
End If
If Not IsNull(AdoRSCustSum![PaymDate]) = True Then
.ParameterFields.GetItemByName("PaymDate").AddCurrentValue CStr(AdoRSCustSum![PaymDate])
End If
If Not IsNull(AdoRSCustSum![PaymRef]) = True Then
.ParameterFields.GetItemByName("PaymRef").AddCurrentValue CStr(AdoRSCustSum![PaymRef])
End If
If Not IsNull(AdoRSCustSum![PaymNotes]) = True Then
.ParameterFields.GetItemByName("PaymNotes").AddCurrentValue CStr(AdoRSCustSum![PaymNotes])
End If
If Not IsNull(AdoRSCustSum![PaymAmnt]) = True Then
.ParameterFields.GetItemByName("PaymAmnt").AddCurrentValue CStr(AdoRSCustSum![PaymAmnt])
End If
End With
If AdoRSCustSum.EOF = False Then
AdoRSCustSum.MoveNext ' Move to next record
End If
Loop
AdoRSCustSum.Close
Set AdoRSCustSum = Nothing
With frmDet
loadMe = True
.CRViewer91.ReportSource = CustSumm
frmDet.CRViewer91.ViewReport
Call WaitTimer(3)
frmDet.CRViewer91.Refresh
frmDet.Show
End With
Set CustSumm = Nothing
Set frmDet = Nothing