Results 1 to 2 of 2

Thread: Help,please Crystal Reports Parameter Values

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304

    Help,please Crystal Reports Parameter Values

    Hi
    can anyone help me with this problem.

    I have a report, which I want to print directly to the printer. When using the viewer, I have no problems with displaying the Parameter Information on the page heading but without it, it just doesn't sem to work.

    The example in Crystal Reports although I believe I followed it correctly isn't thatr clear and well here is what I have coded, if you can see what is wrong, please post a reply.

    Dim DbCn1 As New DbConn()
    Dim dbnam As String
    Dim SqlStr As String
    dbnam = DbCn1.DbName
    Dim Cn1 As New OleDb.OleDbConnection(dbnam)
    Dim Cb1 As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(da2)
    ' Update Property Units with changed Print List flag
    Cn1.Open()
    da2.Update(ds2, "PropertyUnits")
    Cn1.Close()
    Dim Rpt1 As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
    Dim p1 As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
    Dim d1 As New CrystalDecisions.Shared.ParameterDiscreteValue()
    Dim d2 As New CrystalDecisions.Shared.ParameterValues()
    Dim RptLocn As New RptLocn()
    Dim RptPath As String
    Dim Slct As String = "{PropFixandFitt.Property} = " & CStr(thisprprty) & " and {PropFixandFitt.Prt} = 1"


    RptPath = RptLocn.RptLoc
    Rpt1.Load(RptPath & "\FixandFitList.rpt")
    ' Rpt1.RecordSelectionFormula = Slct
    Rpt1.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Portrait

    ' Set the Page Heading to Registered User
    SqlStr = "Select RegisteredUser from SystemValues where sysval = 1"
    Dim Cmd1 As OleDb.OleDbCommand = New OleDb.OleDbCommand(SqlStr, Cn1)
    Cn1.Open()
    Dim Dr1 As OleDb.OleDbDataReader = Cmd1.ExecuteReader()
    Dr1.Read()
    p1 = Rpt1.DataDefinition.ParameterFields.Item("RegUser")
    d1.Value = Dr1("RegisteredUser")
    d2.Add(d1)

    d2 = p1.CurrentValues

    p1.ApplyCurrentValues(d2)
    Rpt1.PrintToPrinter(1, False, 0, 0)

    thanks in advance anyone that can help

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304

    solved my own problem

    well eventually go it to work and if there is anyone else that has had this problem, here is some sample code that works:

    Dim DbCn1 As New DbConn()
    Dim dbnam As String
    Dim SqlStr As String
    dbnam = DbCn1.DbName
    Dim Cn1 As New OleDb.OleDbConnection(dbnam)
    Dim Cb1 As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(da2)
    ' Update Property Units with changed Print List flag
    Cn1.Open()
    da2.Update(ds2, "PropertyUnits")
    Cn1.Close()
    Dim Rpt1 As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument()

    Dim d1 As New CrystalDecisions.Shared.ParameterDiscreteValue()
    Dim d2 As New CrystalDecisions.Shared.ParameterValues()
    Dim RptLocn As New RptLocn()
    Dim RptPath As String
    Dim Slct As String = "{PropFixandFitt.Property} = " & CStr(thisprprty) & " and {PropFixandFitt.Prt}"


    RptPath = RptLocn.RptLoc
    Rpt1.Load(RptPath & "\FixandFitList.rpt")
    Rpt1.RecordSelectionFormula = Slct
    Rpt1.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Portrait

    ' Set the Page Heading to Registered User
    SqlStr = "Select RegisteredUser from SystemValues where sysval = 1"
    Dim Cmd1 As OleDb.OleDbCommand = New OleDb.OleDbCommand(SqlStr, Cn1)
    Cn1.Open()
    Dim Dr1 As OleDb.OleDbDataReader = Cmd1.ExecuteReader()
    Dr1.Read()

    d1.Value = Dr1("RegisteredUser")
    Dr1.Close()
    Cn1.Close()

    d2.Add(d1)

    Rpt1.DataDefinition.ParameterFields("RegUser").ApplyCurrentValues(d2)
    Rpt1.PrintToPrinter(1, False, 0, 0)

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