Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How pass VB6 variable to Crystal Report 7

Posted on 2000-04-07
8
Medium Priority
?
472 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 400 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

636 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