?
Solved

Explain correlation between crystal reports xi parameter and database field

Posted on 2008-06-20
3
Medium Priority
?
1,098 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…
Suggested Courses

801 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