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

Parameter value

Status
Not open for further replies.

alvintse

Programmer
Aug 1, 2003
66
US
Does anyone knows how I can add a space at the beginning of the parameter value in CR 9?
The data on the database that will match the parameter value contains a space at the beginning. So, I have to add a space in order to match that. I can't change the database.

I have tried to enter the parameter value like:" abc" or " abc". (ignore the "") After I click Add, the value becomes "abc".

Thanks.
 
Use the trimleft function on the database field to get rid of the leading blanks.

if ?parma = TrimLeft({database.field}) then
"do this"
else
"do that"
 
Sorry, I forgot to mention that I need the parameter value in the record selection formula to filter out the data returned to the report.
I guess there is nothing I can do with the data before the data returned to the report.

Thanks.
 
Have you tried concatenating a space to the parameter in your Record Selection Criteria?
Code:
{table.field} = " " + {?parm}
I was able to get it to pass it with the value in my test report.

~Brian
 
Hi Brian,
I thought your approach should work.
I tried {table.field} = {?parm} or {table.field} = " " + {?parm}, that should taking care whether the {table.field} contains a leading space or not.

However, the paramter is allowed multiple values, therefore, I might need to loop through all the values and add a space at the beginning. Isn't that too much overhead?

Thanks.
 
Ok.
Create a SQL Expression and call it TrimField.
Add this to the contents of the SQL Expression:
Code:
{fn LTRIM(table.`database_field`)}
In your record selection criteria, add the following:
Code:
{%TrimField} IN {?parm}
This will get passed down to the database.
It will eliminate all spaces from the beginning of the field before comparing it to all choices in the parameter.


~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top