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!

Add Description to Filteritem

Status
Not open for further replies.

sinclairgf

Programmer
Nov 14, 2003
9
US
Does any one know how to add a description value to the filter item. I am trying to allow the user to add filters to the report with blank values. Then later when they go to display the report, the user will be asked to enter in values for all the filter items with blank values. The problem I am having is that you can not enter in blank values for fields that have a datatype of number, date etc. I wanted to put in some number to the filter field and set the description value to dynamic filter value. When I go to display the report I can check for that dynamic filter value by looking at all the filters fields description.

Thanks
 
Do you know what Crystal calls whatever it is that you mean by a filter item?

Using Crystal terminology and including basic info like version of Crystal, Database, example data and expected output will net much better results.

Perhaps you want to set default values for parameters, and then in the record selection formula check for that condition or use what was entered?

An example with a date is to set a default value of 1/1/1970 and then use the following in the record selection formula:

(
if {?MyDateParameter} > cdate(1970,1,1) then
{table.datefield} = {?MyDateParameter}
else if {?MyDateParameter} = cdate(1970,1,1) then
true
)

This will honor what's entered or return all rows if they skip entering anything.

-k
 
I am using Crystal reports 9 and Sql Server. The code below is sample code from crystal that I am using to add a filter.

' *************************************************************
' Add the selected filters
'
Function addFilters(filterFields, filterTypes, filterValues)
Dim operatorObj, filterObj, fieldValueObj
Dim filterField, filterType, filterValue

On Error Resume Next
Set operatorObj = ObjectFactory.CreateObject("CrystalReports.OperatorFilterItem")
operatorObj.Operator = "AND"

for i = 0 to UBound(filterFields)
' Ensure we have valid values for all the fields
if ( (i <= UBound(filterFields)) and (i <= UBound(filterTypes)) and _
(i <= UBound(filterValues)) ) then

filterField = Trim(filterFields(i))
filterType = Trim(filterTypes(i))
filterValue = Trim(filterValues(i))

if (filterField <> &quot;0&quot; and _
filterType <> &quot;0&quot; and filterType <> &quot;1&quot; and _
filterValue <> &quot;&quot;) and _
filterField <> &quot;&quot; and filterType <> &quot;&quot; and filterValue <> &quot;&quot; then

if dbDefController.Datadefinition.Recordfilter.filterItems.count > 0 then _
dbDefController.RecordFilterController.AddItem -1, operatorObj
Set filterObj = ObjectFactory.CreateObject(&quot;CrystalReports.FieldRangeFilterItem&quot;)
Set fieldValueObj = ObjectFactory.CreateObject(&quot;CrystalReports.ConstantValue&quot;)
filterObj.RangeField = findFieldByName(filterField)
addFilterOp filterObj, filterType

fieldValueObj.Value = ConvertToValidFormulaValue(filterObj.RangeField, filterValue)

filterObj.Values.Add(fieldValueObj)
dbDefController.RecordFilterController.AddItem -1, filterObj

end if
end if
next

End Function

I was hoping on using something like filterObj.RangeField.Description = &quot;Dynamic filter&quot;

When I go to view the filter items again I could check the description to tell which filter items need to be prompted for a value before displaying the report to the user.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top