Results 1 to 9 of 9

Thread: Passing parameters to Crystal Reports 6

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Cool

    Hi again!

    I want to find out how to pass parameters to Crystal Reports from a SQL database through VB 6. I am doing reports for my app and I need to know where to begin.

    Sample code would be great if you have it. Thanks in advance for your help.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  2. #2
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Worldwide in the Sun
    Posts
    566

    Hi,

    In your project components activate the crystal report control.

    Put the CR control on a form and change the properties.

    [code]
    CrystalReport1.ReportFileName = "yourreport"
    CrystalReport1.Action = 1

    I always create a tempory print table for my reports
    by using a sql statement.


    That's all.

    Cheers
    Bye
    Ray

  3. #3
    Lively Member
    Join Date
    Feb 2000
    Posts
    120

    crystal reports

    FrmMain.CrystalReport1.Reset
    FrmMain.CrystalReport1.Connect = "dsn=;uid=;pwd=" FrmMain.CrystalReport1.Destination = 0
    FrmMain.CrystalReport1.WindowState = 2 'Window Maximize
    FrmMain.CrystalReport1.DiscardSavedData = True
    FrmMain.CrystalReport1.ReportFileName ="c:\ss\rrr.rpt"
    FrmMain.CrystalReport1.Formulas(i) = formula name="gfgfgfgf"
    FrmMain.CrystalReport1.Action = 1

    hope i helped

    [Edited by shachar on 11-14-2000 at 01:49 PM]
    shachar shaty

  4. #4

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Red face Ok, but...

    Thanks for the input. I may be a little confused, but how do you pass parameters/fields? I'm sorry but I've never used crystal reports before and I am trying to understand what happens? Also, can you suggest a good book on this topic? Or on VB6 and Crystal Reports?

    Thanks again.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  5. #5
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Worldwide in the Sun
    Posts
    566

    Re: Ok, but...

    ok

    In the first place I'm using a separate Crystal Report
    program instead the one supplied by VB.

    What to do in a few steps.

    Open Crystal Report and choose new.
    From the report gallery you can choose custom report
    with data file.
    Choose the database file and you receive a report
    screen where to put data and text.
    Insert fields from the table into the Details section.
    There is also a possibility to insert text fields for
    titles, formula fields, total fields and so on...
    After finishing just look with preview to check the layout.

    There is a great online help in the report generator.

    Good Luck
    Ray



    Ray

  6. #6
    Lively Member
    Join Date
    Feb 2000
    Posts
    120
    i cannot remember what is the way of using parameters but if you are building your report on a store procedure you will have under crystal reports something like command... or param.... i dont realy remember but if you still have the problem reply and i will try my best to help you
    shachar shaty

  7. #7

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy Need more help...

    Hi again!

    I need to know what command line(s) I need to add in VB in order to pass one parameter (i.e. ID number) from VB6 to a Crystal Report. The version I have is 6.0. I have already set up the report in Crystal and it is opening in the application, but it is giving me all the records. Basically, I just want Crystal to print the data that is on the form where the user is viewing the data. Any ideas/suggestions? I hope this isn't confusing. Thank you in advance.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  8. #8
    New Member
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4

    Talking

    I think you would like to know about this..
    with Crystal1
    .ReportFileName = App.Path & "\RCDLossDaily.rpt"
    .Destination = crptToWindow
    .ParameterFields(0) = "PName1;" & Value & ";TRUE"
    .ParameterFields(1) = "PName2;" & strStop & ";TRUE"
    .Action = 1
    End with

    Set True = CR will not prompt to enter parameter

  9. #9

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Thumbs up Thanks!

    Marex, Shachar, & Superdorm,

    Thank you for all your help. I was able to solve my problem.

    Thank you to infinity!
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

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