Solved

Explain correlation between crystal reports xi parameter and database field

Posted on 2008-06-20
3
1,082 Views
Last Modified: 2010-05-18
I finally have my crystal reports set up to read my sql server database. I finally have my VB code set up to allow me to change a parameter value in my report.

Could someone explain to me how to set up my parameter now in Crystal so the parameter is directly linked to a specific field in my report.

For example, I have a table full of client names. Each client name is identified by a unique id number. In my report now, I get a listing of all of my clients. But let's say I wanted to set up a parameter, that I can change the value of this in my VB program, to only show say a client whose unqiue id is equal to X.

I'm really confused on the tie in between a specific field on my report and how the parameter ties into that.

If someone could explain that, that would be a huge help!

Thanks!
0
Comment
Question by:samic400
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 21835545
I follow what you want.

If you run the report you are prompted for a client name.  When you select one and hit ok does the report show?

If you are trying to filter based on that name you can use the SELECT EXPERT under the REPORT menu.
Select the ClientName field
Click =
Select the parameter field

mlmcc
0
 
LVL 7

Accepted Solution

by:
Dauhee earned 500 total points
ID: 21837981
in your instance you don't need a parameter and can leave it as is as that is a little bit more complex. You can use selectioncriteria instead as its more intuitive to those that understand SQL where clause filtering (can do AND, OR, IN etc)

When you want to generate via VB you can use code like following:

            frmMain.crptDynamicReport.ReportFileName = "C:\report.rpt"
            frmMain.crptDynamicReport.UserName = xxxr
            frmMain.crptDynamicReport.Password = xxx
            frmMain.crptDynamicReport.Connect = "dsn= mydsn;uid=user;pwd=password"
            frmMain.crptDynamicReport.SelectionFormula = xxx

the username & password is set twice for a reason, just can't remember off the top of my head

the SelectionFormula would be the filter of the unique client id. You can determine what the formula is by going into the report via following menus:

report\selection formulas\record selection

from there you can use the gui to select the relevant client id field so it would be something like:
{TABLENAME.FIELDNAME} = "XXXX"
where XXXX is the value you want to filter on. Remember to cancel out of this screen without saving as you could inadvertantly hardcode a test value in there - this is a common enough developer error and can be extremely confusing!!

Watch out for escaping the inverted quotes - you can use inverted commas instead as crystal reports will also accept those.

As a general word on crystal reports. Good luck - because you will need it. In their infinite wisdom they use 1 error message to arise for 100 different problems!
0
 
LVL 13

Author Comment

by:samic400
ID: 21838176
mimcc,

I really don't want to prompt the user at all but would rather pass an SQL string instead to the report. Should I be using the selectionformula method instead and build my SQL statement and pass it that way rather than parameters?
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

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…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

22 Experts available now in Live!

Get 1:1 Help Now