Results 1 to 6 of 6

Thread: how to pass parameters to a report

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Location
    Mexico
    Posts
    20

    how to pass parameters to a report

    hi!

    im newbi here..

    i want to know how to pass parametersfrom a from on vb to a report.. if the user enters a string to search for i want to show a report correponding only to that sting.. how i do it__
    im using vb 6.0 and crystal reports 8.0

    thx
    Can you live with yourself
    when you think of what
    you left behind?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    In Crystal, add a Parameter to your report (Insert -> Field Object -> Parameter Fields)

    Then modify the Record Selection formula so that the database field must be equal to the parameter field. For example,

    {Authors.LastName} = {?AuthorName}
    Crystal will then use this information to create a SQL statement to the database, ie

    Select * From Authors Where LastName = 'King'

    Then in VB, there are two methods to prompt the user. Let Crystal handle everything or do it yourself. By default, Crystal will automatically prompt the user for the paramter values.

    How do you currently show the report in VB? Let me know if you want information on handling the parameters your self.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Location
    Mexico
    Posts
    20
    thanx..

    i want to set that formula from my vb aplication, i added a crystal report control and someone told me that i can use the formulas property to send the formula to the reporte already done, then crystal will use that record formula..

    but id ont know how to set the formulas property... vb just sends me syntaxis errors..

    i have these lines and i set some other parameters of the report in other form, like the reportName

    me.CrystalReport1.Formulas="{asistencias.id_alumno}='"&me.DBLAlumnos.BoundText&"' "
    Me.CrystalReport1.WindowTitle = Me.txtWindowTitle Me.CrystalReport1.DataFiles(0) = Me.txtReportDBName Me.CrystalReport1.ReportFileName = Me.txtReportName Me.CrystalReport1.CopiesToPrinter = Me.txtCopias

    i have a DBList control which shows the students name, so if i select an item it should send the ID (alumno_id) to the formula, to get just the report of that student..

    thx for all..
    Can you live with yourself
    when you think of what
    you left behind?

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    You need to set the selection formula

    VB Code:
    1. me.CrystalReport1.SelectionFormula = "{asistencias.id_alumno}='"& me.DBLAlumnos.BoundText & "'"

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Location
    Mexico
    Posts
    20
    thanx..

    i just tried the code, and it stopped sending syntaxis errors, but now when i run the application it sends an error:

    20515: Error in file asistencias.rpt
    Error in Formula <recod_selection>

    The remaining text does not appear part of the formula

    ...................

    if i run this formula in the crystal report it does work but not from my application, what can be happening??
    Can you live with yourself
    when you think of what
    you left behind?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2004
    Location
    Mexico
    Posts
    20
    i found the reason...

    i should use another property, this is the code...

    Me.CrystalReport1.ReplaceSelectionFormula ("{asistencias.id_alumno}='" & Me.DBLAlumnos.BoundText & "'")


    thanx to all..
    Can you live with yourself
    when you think of what
    you left behind?

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