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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating parameter as string type 1

Status
Not open for further replies.

kazcadman

IS-IT--Management
Apr 8, 2003
14
0
0
GB
Hi, Can anyone help.

I have a report where the user would like to be prompted for a variety of options, ie Works Order Number, Part Number, Customer Order Number etc. After having spent days trying to get records to show when only one parameter is entered I found an article on Crystal Decisions which explains how to do it 'Create report so that you are not required to enter a value for all parameters'. I have followed their example exactly. I have created a parameter which is WORDNo and have set type as string. I have then created the following formula as per their example

(if {?WORDNo} <>&quot;&quot; then {MBF010.WORDNO}=tonumber({?WORDNo}) or {?WORDNo}=&quot;&quot;)

The above should work but i keep getting message that 'A String is required' Can anyone advise where i am going wrong. I can't believe such a simple requirement is causing me so many problems.

Thanks
 
you could use


{?WORDNo} =&quot;&quot; or
({?WORDNo} <>&quot;&quot; and {MBF010.WORDNO}=tonumber({?WORDNo}))
 
Right click the field {MBF010.WORDNO} in your field explorere and I think that you'll discover that it's a string, not a number, so change the formula to:

(if {?WORDNo} <>&quot;&quot; then {MBF010.WORDNO}={?WORDNo} or {?WORDNo}=&quot;&quot;)

-k
 
Thanks very muck K, you were right, it was a string. In every other table in the database this field is a number, i had come across this problem before but had forgotten. Won't forget this again in a hurry.

Thanks very much
 
Hi,

Thanks very much for previous advice, however i'm stuck on a second parameter.I have a date field (it is definetely a date field) crystal decisions suggests setting up a parameter for the date range as a string field and then applying the following

(If{?WORDadded}<>&quot;&quot; then {MBF010.WORDADDED} = Date({?WORDadded}) else {?WORDadded}=&quot;&quot;)

(WORDADDED is the date works order added field).

The above is suggests should be added after my first parameter option in the record selection after an 'or' command.

However i keep getting the following error:
A date-time is required here - it then places cursor after Date(
Yet again i assume i'm doing something very simple wrong. I have checked that the default for the report is for date only not date-time.

Can anyone help.

Thanks
Kaz
 
What type of parameter is {?WORDadded}?

It appears to be a string, so you'll have to have it formatted according to how the DATE function expects it.

I'd use a real date field and create a default of 1/1/1960 or some such and check against it.

(
If {?WORDadded}<> date(1960,1,1) then {MBF010.WORDADDED} = {?WORDadded}
else if
{?WORDadded} = date(1960,1,1)
then true
)

-k
 
The field in the report is actually formatted as a date, if i browse on the field it tells me it is a date field. That has been my main problem, trying to select the date as a string in the parameter (crystal decisions says i need to do this to allow the parameter to remain empty)and then convert back to a date in the selection formula.

I'll have a proper look at your latest suggestion tommorow. Thanks.
 
Fantastic..... the report now works as i wanted it to.

Thanks very much for all your help.
Kaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top