Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter Field 1

Status
Not open for further replies.

Parasu

Technical User
Mar 11, 2001
38
PH
Hi there,
How do I use a parameterized report. Suppose, I want to select the Contact_Id at runtime and based on the value I enter, the report should list only records particular to the parameter I give.
Ive created a parameter field and Ive included it inside the report design. In the code, rs.Open "select...." when I check with the table's field contact_id, how do I refer to the parameter field? The parameter field name is given as
?contact_id. But, ? cannot be used in the select statement
Pls give me the code for how to use the parameter field in the rs.open "select.."
How is this done in Crystal Report 8. Im using VB6 and cr8

Cheers

Parasuraman
Parasuraman
 
Parameters are a two step process. I sounds like you got the first step in creating the parameter. You now need to use the parameter in the selection formula for the report. You can use the Select Expert and insert the parameter in the select expert or you can take it a step further and go into the record selection formula editor and write your own formula to use the selection criteria. Then when you run the report, you will be prompted for the parameter field.
 
Dear BradW,
Thanx alot for that piece of info. The runtime parameter is working now.
I have another doubt. I tested with a string field, its working fine. How about passing a datetime datatype as a parameter? Should both the date and the time has to be exactly matched with the value in the database? I don't understand.
For instance, if I want to see all the employees joined between 29/04/20001 and 29/05/2001, (remember, i have datetime datatype in my access table for the joining_date field), the parameter is asking even for the time? It wont be possible to remember the time. So, what is the workaround in a situation like this.

Thanx again for ur timely support.

Parasuraman
Parasuraman
 
Ah the old datetime field problem. I have an Oracle database with many datetime fields that are using date only. The best way that I've found to deal with this is to create a formula that converts the datetime field to date only, the formula would be like this:

date({datetime field})

Then create two parameters, one for start date and one for end date, assuming that you want to do this as a range. Make sure to define each parameter as a DATE data type, NOT datetime.

Then when selecting the data use the FORMULA as your selection field and insert the parameters in to the selection such as:

@date_formula is between ?{start_date} and ?{end_date}

Let me know if you have further questions. I have successfully used this trick many times and it eliminates the time portion of the field and allows you to use parameters to select from only a date range.

Brad
 
Thanx Brad,
I'll work on it and definitely let you know. Thanx again

Cheers
Parasuraman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top