Results 1 to 8 of 8

Thread: crystal parameter

  1. #1

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

    crystal parameter

    I'm running a crystal report through my app. I have a date variable set in the application "TranPeriodEnd" . I need to place this date in the top of the report. Heres the code I'm using but Crystal gives me a dialog box asking for the parameter... In the report I created DateParam, using: field explorer --> parameter fields...am I doing something wrong here?


    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
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Your code works for me, however you can add the value to the reportviewer fairly easy.
    VB Code:
    1. Dim crReport As New header
    2. CRV.ReportSource = crReport ' CRV is the reportviewer
    3. Dim crParameterDiscreteValue As New ParameterDiscreteValue
    4. crParameterDiscreteValue.Value = CDate(tranperiodend)
    5. CRV.ParameterFieldInfo("Dateparam").CurrentValues.Add(crParameterDiscreteValue)
    I am almost sure you are setting the report source in the code not in the designer but it worths checking it again.

    Anyway, If i were you I would have used a Formula Field instead of Parameter Field. Each time you do a refresh or something you should again pass the parameter, and thats just a pain in the neck.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    yes I am setting the report source in the code.

    VB Code:
    1. CrystalReportViewer1.ReportSource = rpt

    whats the difference between setting it in the code or the designer? Would that cause Crystal to prompt me for a parameter?


    how do you set it in the designer?
    It's tough being an unhandled exception...

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

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    If you set it in the designer, then the viewer uses that which is different from the instance you create at the code and set parameter value for it.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    hey luna, when you say you got it to work...did Crystal prompt you for a value? did you use your own variable?
    It's tough being an unhandled exception...

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

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I mean the CR didnt prompt for parameter and my value was there.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  7. #7

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    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

  8. #8
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Ya, i did. aren't you kind of refreshing your report after adding that value?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

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