Solved

How pass VB6 variable to Crystal Report 7

Posted on 2000-04-07
8
434 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
[X]
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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

726 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