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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Date variable from VB to crystal

Status
Not open for further replies.

rotomd

IS-IT--Management
Nov 1, 2004
11
US
Do I need to do anything special for this? I keep getting parameter errors when I try this code...

the two date parameters are set as dates in crystal.
Code:
Private Sub Command1_Click()
Dim sd, ed As Date
Dim sp As String
Dim cr As CrystalReport

    If sales_person_combo.Text = "" Then
        MsgBox "No Sales Person Entered", vbExclamation, "Error"
        Exit Sub
    End If
    sp = IIf(sales_person_combo.Text = "All Sales Persons", "*", sales_person_combo.Text)
    sd = Calendar1.Value
    ed = Calendar2.Value
    
    Set cr = main!CrystalReport1
    With cr
        .DiscardSavedData = False
        .ReportFileName = "\\dexter\shared\it dept\bid_db\salesperson_and_date_report.rpt"
        .ParameterFields(0) = "sales_person_parameter;" & sp & ";true"
        .ParameterFields(1) = "start_date_parameter;" & sd & ";true"
        .ParameterFields(2) = "end_date_parameter;" & ed & ";true"
        .Action = 0
    End With
end sub
 
What is the error? Could it be caused by 'sd' being declared as a variant?

zemp
 
Also what version of Crystal are you using? Which crystal objects are you using?

zemp
 
The error is "invalid parameter"

I'm thinking now I might have my parameter field indexes messed up. is there any way to find out the exact index of a parameter (i know it's based on when they parameter was created)...?
 
crystal reports 8.5 and I'm using crystl32.ocx
 
ok, I figured it out.. you have to pass the date field like this..

Code:
.Parameter(0) = "date_parameter;Date(YYYY,MM,DD);True"
 
Glad to hear it and thanks for posting your solution. It will help someone else down the line.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top