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

x
?
Solved

Explain correlation between crystal reports xi parameter and database field

Posted on 2008-06-20
3
Medium Priority
?
1,106 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
[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
3 Comments
 
LVL 101

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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 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