Solved

How pass VB6 variable to Crystal Report 7

Posted on 2000-04-07
8
394 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
Comment Utility
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
Comment Utility
I don't think that you can.
0
 
LVL 1

Expert Comment

by:ndb
Comment Utility
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
 

Author Comment

by:eyoung
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:ndb
Comment Utility
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
Comment Utility
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
Comment Utility
The answer my friend ... is blowing in the wind ... ;0)
0
 

Author Comment

by:eyoung
Comment Utility
Thanks ndb
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now