Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How pass VB6 variable to Crystal Report 7

Posted on 2000-04-07
8
429 Views
Last Modified: 2008-08-05
I have written a Visual Basic 6.0 program that prompts the user for some string information.  I want to pass that string information to a Crystal Report 7.0 report and have the report print the string information in the title of the report.

How do I pass a variable (string information) from VB to CR?

Thanks,
EYoung
0
Comment
Question by:eyoung
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:ndb
ID: 2693532
Add a Crystal reports control on a form.
Then place the following code:

****************

Private Sub cmdReport_Click()
    Dim varParams
   
    ReDim varParams(1)

        With CrystalReport1
            .Connect = conConnection.ConnectionString
            .Destination = crptToWindow
            .ParameterFields(0) = "IDNumb;" & ListView1.SelectedItem.SubItems(7) & ";True"
            .ParameterFields(1) = "ParNumb;" & ListView1.SelectedItem.SubItems(8) & ";True"
            .ReportFileName = App.Path & "\MetaLog.rpt"
            .Action = 1
        End With
End Sub

***************

IDNumb and ParNumb are names of Parameters in Crystal Reports.
0
 
LVL 2

Expert Comment

by:Jagar
ID: 2693533
I don't think that you can.
0
 
LVL 1

Expert Comment

by:ndb
ID: 2693538
Don't dim varParams.
It is just something I used in my program. You don't need it.
You only need the part between the with statements.
Parameters to Crystal are send:
"<ParamName>;<ParamValue>"
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:eyoung
ID: 2693781
ndb,

In your statement:

..ParameterFields(0) = "IDNumb;" & ListView1.SelectedItem.SubItems(7) & ";True"

If I wanted to just send one value say "123" to the report, would the VB line read:

..ParameterFields(0) = "IDNumb;" & "123" & ";True"

If this is correct, is the "IDNumb" the name of the CR Parameter field?  Also, what is ";True" used for?

Thanks for the quick help,
Regards,
EYoung
0
 
LVL 1

Expert Comment

by:ndb
ID: 2693813
Indeed. IDNumb is a CR Parameter field.
If you set False instead of True,
Crystal Reports will set 123 as default value but will still show the dialog to ask the parameter.
If you set it to True, Crystal reports doesn't show that dialog anymore and uses the given value.
0
 

Author Comment

by:eyoung
ID: 2693858
ndb,

Thanks.  That works.  Please convert your comment to an answer and I'll accept it.  

I will accept it when I get back to this office tomorrow. Off to the client to apply this answer.

Thanks again for the help and quickness of your response.

Regards,
EYoung
0
 
LVL 1

Accepted Solution

by:
ndb earned 100 total points
ID: 2694823
The answer my friend ... is blowing in the wind ... ;0)
0
 

Author Comment

by:eyoung
ID: 2695272
Thanks ndb
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question