Results 1 to 9 of 9

Thread: Criteria printed in Crystal Reports

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Hi, everybody!

    I'm using 2 text boxes in a form as criteria to a SQL which feeds a Crystal reports. It's working nice, the problem is that I'd like the contents of the 2 text boxes (which are the report initial and final dates) to be displayed and printed in the report.

    How can I do that?

    Thanks in advance,
    Roselene

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124

    Post

    Can you set the fields up as parameters in the crystal report and pass the values in before you execute the report?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Bsmith,

    Thanks for taking the time to help me. Could you please give me any further information? I'm afraid I can't understand your suggestion.

    Thanks again,
    Roselene

  4. #4
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124

    Post

    I guess my first question is are you running the Crytal Report from the Visual Basic program? If you are then inside Crystal Reports you can create a field that is a parameter. Before you set the Action=1 on the report you can set the parameters like this.
    Code:
        crystalreportobject.ParameterFields(0) = txtTextbox.Text
    Your parameter fields should be populated with the values supplied from your code.

    If you are not using VB to generate your report, then you may need to add the fields to your select from your database.

    I hope this helps. I may need to see some code if you need more detail.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    bsmith,

    Yes, I'm running Crystal reports from the VB program. There are 2 option buttons (Same name, different indexes) in a form in order to allow the user tho choose which report he/she wants to see/print.

    I've put your suggestion in this option button click event:

    CrRepNext.ParameterFields(0) = TxtDateIni.Text
    CrRepNext.ParameterFields(1) = TxtDateFin.Text

    but I have received the following error message:
    4830 object doesn't support this property or method.

    When I see the list of properties for my Crystal reports object (CrRepNext or CrRepNext1), it doesn't show a property called "Parameter Fields". I must be doing something wrong, but I can't put my finger on it.

    Thanks again for all of your help,
    Roselene


    This is the whole code for the event, in case you want to take a look:

    Private Sub OptBtReports_Click(Index As Integer)
    On Error GoTo ExecuteReportFail
    Select Case Index
    Case Is = 0
    If DtReports1.Recordset.RecordCount = 0 Then
    MsgBox "No data"
    Else
    CrRepNext.WindowState = crptMaximized
    CrRepNext.ParameterFields(0) = TxtDateIni.Text
    CrRepNext.ParameterFields(1) = TxtDateFin.Text
    CrRepNext.PrintReport
    Case Is = 1
    If DtReports2.Recordset.RecordCount = 0 Then
    MsgBox "No data"
    Else
    CrRepNext1.WindowState = crptMaximized
    CrRepNext1.ParameterFields(0) = TxtDateIni.Text
    CrRepNext1.ParameterFields(1) = TxtDateFin.Text
    CrRepNext1.PrintReport
    End if
    End Select
    Exit Sub
    ExecuteReportFail:
    MsgBox CStr(Err) + Error
    ' Resume OptBtReports_Click_Exit
    End Sub


  6. #6
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124

    Post

    I am confused if the ParameterField property is not available. This is the property I use to set a parameter in the report. Did you try to use the help inside the Crystal Report designer? There might be some information there on passing parameters to the report. Sorry I couldn't be more help.

  7. #7
    Lively Member
    Join Date
    Mar 2000
    Location
    Fort Lauderdale, FL USA
    Posts
    112
    Create two textboxes where you want the dates to appear and then do something like this:

    Private Sub Form_Load()

    Dim Report As New CrystalReport1
    Dim sStart as String
    Dim sEnd as string

    sStart = form.text1.text
    sEnd = form.text2.text

    Report.Text1.SetText sStart
    Report.Text2.SetText sEnd

    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport

    End Sub

    That should work.
    Damonous

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Damonous:

    I've tried you suggestion, but have received the error message:
    User defined type not defined
    regarding to the expression CrystalReport1 in the line:

    Dim Report1 as New CrystalReport1

    As I get an error message trying to use the bsmith's suggestion also, I guess that's something wrong with my VB. Is it possible that I have installed VB with some components missing? What should I do then?

    Thanks again, folks
    Roselene

  9. #9
    Lively Member
    Join Date
    Mar 2000
    Location
    Fort Lauderdale, FL USA
    Posts
    112
    The "CrystalReport1" in the Dim Report1 as New CrystalReport1 statement should be replaced with the name you gave the report.
    i.e. if you named the report Inventory, the Dim would be:

    Dim Report1 as New Inventory

    Try that before you decide to reinstall VB. :)
    Damonous

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