Results 1 to 4 of 4

Thread: crystal parameter field

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    crystal parameter field

    is there a way to stop Crystal from prompting me for a value. I already have the value that I need stored in crParameterDiscreteValue.Value



    VB Code:
    1. Dim crReport As New header()
    2.         Dim crParameterFieldDefinitons As ParameterFieldDefinitions
    3.         Dim crParameterFieldDefinition As ParameterFieldDefinition
    4.         Dim crParameterValues As New ParameterValues()
    5.         Dim crParameterDiscreteValue As New ParameterDiscreteValue()
    6.         crParameterDiscreteValue.Value = CDate(tranPeriodEnd)
    7.         crParameterFieldDefinitons = crReport.DataDefinition.ParameterFields
    8.         crParameterFieldDefinition = crParameterFieldDefinitons.Item("Dateparam")
    9.         crParameterValues = crParameterFieldDefinition.CurrentValues
    10.         crParameterValues.Add(crParameterDiscreteValue)
    11.         crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    cant understnad why your code does not work, here is ours and it works perfectly:


    Dim p2 As New ParameterFields

    Dim p1 As New ParameterField
    p1.ParameterFieldName = "RegUser"
    Dim d1 As New ParameterDiscreteValue
    d1.Value = RegisteredUser.CurUsr
    p1.CurrentValues.Add(d1)
    p2.Add(p1)

    CrystalReportViewer1.ParameterFieldInfo = p2

    and looks exactly the same

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    how did you create a parameter field in crystal?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  4. #4
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    In the report designer, from field explorer, parameter field and then selected new.

    I did have the same problem as you but that was just because I misspelt the name.

    We use parameter fields of type string and date and they all seem to work, although frustratingly it took me ages to get them to work even though I carefully followed the examples.

    The solution posted is for Crystal Reports Viewer

    the following is the equivalent for when dealing with a report document and exporting the file in pdf format, but that is also the same for print to printer

    both are working examples of code:

    Dim d1 As New ParameterDiscreteValue
    Dim p1 As New ParameterValues
    If Not IsDBNull(dr1("CompanyName")) Then
    d1.Value = dr1("CompanyName")
    Else
    d1.Value = " "
    End If
    p1.Add(d1)
    Rpt1.DataDefinition.ParameterFields("CompanyName").ApplyCurrentValues(p1)

    Dim d2 As New ParameterDiscreteValue
    Dim p2 As New ParameterValues
    If Not IsDBNull(dr1("Address1")) Then
    d2.Value = dr1("Address1")
    Else
    d2.Value = " "
    End If
    p2.Add(d2)
    Rpt1.DataDefinition.ParameterFields("Address1").ApplyCurrentValues(p2)

    Dim d3 As New ParameterDiscreteValue
    Dim p3 As New ParameterValues
    If Not IsDBNull(dr1("Address2")) Then
    d3.Value = dr1("Address2")
    Else
    d3.Value = " "
    End If
    p3.Add(d3)
    Rpt1.DataDefinition.ParameterFields("Address2").ApplyCurrentValues(p3)


    Dim d4 As New ParameterDiscreteValue
    Dim p4 As New ParameterValues
    If Not IsDBNull(dr1("Address3")) Then
    d4.Value = dr1("Address3")
    Else
    d4.Value = " "
    End If
    p4.Add(d4)
    Rpt1.DataDefinition.ParameterFields("Address3").ApplyCurrentValues(p4)

    Dim d5 As New ParameterDiscreteValue
    Dim p5 As New ParameterValues
    If Not IsDBNull(dr1("Address4")) Then
    d5.Value = dr1("Address4")
    Else
    d5.Value = " "
    End If
    p5.Add(d5)
    Rpt1.DataDefinition.ParameterFields("Address4").ApplyCurrentValues(p5)


    Dim d6 As New ParameterDiscreteValue
    Dim p6 As New ParameterValues
    If Not IsDBNull(dr1("StationeryChoice")) Then
    d6.Value = dr1("StationeryChoice")
    Else
    d6.Value = " "
    End If
    p6.Add(d6)
    Rpt1.DataDefinition.ParameterFields("StationeryChoice").ApplyCurrentValues(p6)


    dr1.Close()
    Cn1.Close()
    Cmd1 = Nothing
    Cn1 = Nothing
    Dim RptPth As String = Application.StartupPath
    Dim stopat As Integer = RptPth.LastIndexOf("\bin")
    If stopat > 0 Then RptPth = Mid(RptPth, 1, stopat)
    Dim exp1 As New ExportOptions
    Dim dsk1 As New DiskFileDestinationOptions
    Dim Fnam As String = RptPth & "\emails\" & "Remittance advice for " & CStr(ServiceProvider) & "-" & Trim(Name) & ".pdf"
    exp1 = Rpt1.ExportOptions
    exp1.ExportFormatType = ExportFormatType.PortableDocFormat
    exp1.ExportDestinationType = ExportDestinationType.DiskFile
    dsk1.DiskFileName = Fnam
    exp1.DestinationOptions = dsk1
    Rpt1.Export()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width