Solved

Explain correlation between crystal reports xi parameter and database field

Posted on 2008-06-20
3
1,086 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

808 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