Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Location
    Wales, UK
    Posts
    42

    Unanswered: Simple Problem - For someone in the know

    Right i have Crystal Reports 10 Dev & Visual Studio.Net 2003

    I've made a form that has a Datepicker called DateTimePicker1 and a textbox called TextBox1. I have a report called HORSSRZERO.rpt. On the form the date picker and text box are at the top and next to them is a button to display the report. Under them is the CrystalReportViewer thingy.

    What i need to happen is you choose a date, enter a supplier (six digit number) and click the button and the report displays with these TWO DIFFERENT parameters (sorry for caps them but i've posted this on a few different forums but they keep giving me the code for a range!). Here is the code i got so far. But when i run it the default parameter window pops up asking for the date.
    Here is the code.
    Thanks

    Imports CrystalDecisions.Shared
    Imports CrystalDecisions.CrystalReports.Engine

    Public Class Form2
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "


    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    CrystalReportViewer1.DisplayGroupTree = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim myParameterFields As New ParameterFields
    Dim myParameterField As New ParameterField
    Dim myDiscreteValue As New ParameterDiscreteValue


    myParameterField.ParameterFieldName = "Date"
    myDiscreteValue.Value = DateTimePicker1.Text
    myParameterField.CurrentValues.Add(myDiscreteValue )

    myParameterFields.Add(myParameterField)

    myParameterField.ParameterFieldName = "Supplier"
    myDiscreteValue.Value = TextBox1.Text
    myParameterField.CurrentValues.Add(myDiscreteValue )

    myParameterFields.Add(myParameterField)

    CrystalReportViewer1.ParameterFieldInfo = myParameterFields

    CrystalReportViewer1.ReportSource = "c:\HORSSRZERO.rpt"
    CrystalReportViewer1.Refresh()

    End Sub
    End Class

  2. #2
    Join Date
    Jan 2005
    Location
    Avon Lake, OH
    Posts
    112
    Talking with one of my Crystal Reports 10 / VB6 developers, she had a couple of ideas:


    1. Make sure that EnableParameterPrompting is turned off (False) for the main report, and for any subreports.

    2. Crystal may be expecting a date variable instead of the string that you are sending it.

    Hope this helps!

  3. #3
    Join Date
    Feb 2005
    Posts
    3
    Try this:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim myParameterFields As ParameterFields
    Dim myParameterField As ParameterField
    Dim myDiscreteValue As ParameterDiscreteValue

    myParameterFields = New ParameterFields
    myParameterField = New ParameterField
    myDiscreteValue = New ParameterDiscreteValue

    myParameterField.ParameterFieldName = "Date"
    myDiscreteValue.Value = DateTimePicker1.Text
    myParameterField.CurrentValues.Add(myDiscreteValue )

    myParameterFields.Add(myParameterField)

    myParameterField = New ParameterField
    myDiscreteValue = New ParameterDiscreteValue

    myParameterField.ParameterFieldName = "Supplier"
    myDiscreteValue.Value = TextBox1.Text
    myParameterField.CurrentValues.Add(myDiscreteValue )

    myParameterFields.Add(myParameterField)

    CrystalReportViewer1.ParameterFieldInfo = myParameterFields

    CrystalReportViewer1.ReportSource = "c:\HORSSRZERO.rpt"
    CrystalReportViewer1.Refresh()

    End Sub

  4. #4
    Join Date
    Feb 2005
    Location
    Wales, UK
    Posts
    42

    Omg!

    sagesmith7! Your a Star!

    If i could i would buy you a beer (or 3). So i'm now guessing if i wanted to pass a 3rd parameter all i would need to do is add
    myParameterField = New ParameterField
    myDiscreteValue = New ParameterDiscreteValue
    between each parameter.

    Now all i need to do is work out a bit of VB magic on the date field (maybe you can help)

    On the datetimepicker if they select a date i need to pass the date of the last sunday of that month to the report on what is selected. Any Ideas?

    Again i can't thank you enough!!!!!

Posting Permissions

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