I have a report created with autosearch fields. How can I fill these fields in RAP, eg, intercept before the form is showed and fill the fields (and preventing the user from editing it)?
Use the RAP global OnCreate event to set the search expression values. To make the search criteria non editable, you'll have to create a custom autosearch dialog and control which fields are editable by using a RAP pass through function. There are examples of creating a RAP pass through function in the RAP demos of the RBuilder installation.
Your other alternative is to remove the field as an autosearch field and set the criteria value on the dataview in code. Here is an example of extracting the TdaSQL object to access the search criteria fields. Set the field's Autosearch property to false. This way the field won't be used in the autosearch dialog, but the criteria value you supply in code will be used in the generation of the SQL for the report. Since the autosearch fields have already been created, you'll need to free the ones that you are going to turn off. There are two sets of objects, the dataviews' SearchCritreia objects are persistent in the template as part of the dataview. The autosearch fields are created at runtime and are not persistent. The autosearch fields are used at runtime (created automatically since you have dataviews with search criteria objects) in order to perform the search, as shown in the autosearch demos.
Comments
make the search criteria non editable, you'll have to create a custom
autosearch dialog and control which fields are editable by using a RAP pass
through function. There are examples of creating a RAP pass through
function in the RAP demos of the RBuilder installation.
Your other alternative is to remove the field as an autosearch field and set
the criteria value on the dataview in code. Here is an example of
extracting the TdaSQL object to access the search criteria fields. Set the
field's Autosearch property to false. This way the field won't be used in
the autosearch dialog, but the criteria value you supply in code will be
used in the generation of the SQL for the report. Since the autosearch
fields have already been created, you'll need to free the ones that you are
going to turn off. There are two sets of objects, the dataviews'
SearchCritreia objects are persistent in the template as part of the
dataview. The autosearch fields are created at runtime and are not
persistent. The autosearch fields are used at runtime (created automatically
since you have dataviews with search criteria objects) in order to perform
the search, as shown in the autosearch demos.
http://www.digital-metaphors.com/tips/ExtractSQLObject.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com