Crystal Reports - default options
In Crystal reports, you can define default values ββfor report parameters.
For example, I might have a date range and a default start setting of 12/01/2008 and a default end of 12/31/2008.
Is it possible to change these defaults at runtime? For example:
1 - By default on the first and last days of the current month?
2 - By default on the first and last days of the tax calendar with a proprietary company? (i.e. search for it in the database)
3 - First and last days of the current year?
You understand. Is it possible? I would even be open to a solution that involved launching an external application to access the reports and modify them, if anyone knows how.
Edit:
To answer the question asked by Philippe Grondier, most of these reports are run from within the application. I was hoping for something simpler than manipulating a crystal object at runtime; I now have my hands on figuring out other parts of this API. However, I could look to the future.
source to share
Are you planning to run the crystal report from the Crystal Reports interface, or as an add-in built into another program (for example, you can use Crystal Reports ActiveX Designer Runtime Support - craxdrt.dll - in VB code)? In this latter case, you can manipulate each report object before launching. Then objects such as parameters can be updated according to your needs.
As a simple example of such a runtime update, my report printing routine will check to see if the report has a field named "printed". If this field is found, its value will be set to the domain name of the user requesting the report and printed.
At a higher level, you can even change the SQL line of the report to add specific filters that can be inherited from your code. This way you don't need parameters anymore: let your code add filter values ββon the fly
EDIT: Some code examples:
(m_rapport is CRAXDRT.report object, ActiveSession is my current session object)
If m_rapport.ParameterFields.Count > 0 Then
For i = 1 To m_rapport.ParameterFields.Count
If m_rapport.ParameterFields(i).Name = "{?PUB_DateDebutPeriode}" Then
m_rapport.ParameterFields(i).AddCurrentValue CDate(DateValue(sessionActive.dateDebutPeriode))
End If
If m_rapport.ParameterFields(i).Name = "{?PUB_DateFinPeriode}" Then
m_rapport.ParameterFields(i).AddCurrentValue CDate(DateValue(sessionActive.dateFinPeriode))
End If
If m_rapport.ParameterFields(i).Name = "{?PUB_id_Personne}" Then
m_rapport.ParameterFields(i).AddCurrentValue StringFromGUID(clientActif.id_Personne)
End If
Next i
Endif
I also have another function to change the data source of a report at runtime so that the reports can run on different servers / locations.
source to share
Read my publication Crystal Reports: Name and Date Range Options . You may be able to use this technique for your own purposes.
source to share