Solved

Explain correlation between crystal reports xi parameter and database field

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Window placement 17 77
Validating VB6 Function 19 56
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 47
TT Auto Dashboard 13 85
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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

864 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

24 Experts available now in Live!

Get 1:1 Help Now