Replacing autosearch values during report printing.
(RB Pro 6.03)
Our users can create reports using the end-user designer in our app. They
can set AutoSearch criteria in the designer for certain fields and if those
fields are selected for AutoSearch,we replace the SearchExpression at print
time with a "currently selected value" from our application. It works great
for four key string fields we have in our app.
But we now also want to provide similar functionality for dates. For
example, the user selects a date field as an AutoSearch field, selects >= as
the operator and then enters "LAST_YEAR_START" in the value field. I then
want our app to detect the value of "LAST_YEAR_START" in the
SearchExpression at runtime and translate it to last year's starting date.
I would like to do this with other "defined" date values as well such as
LAST_MONTH_START, LAST_MONTH_END, etc.
But when I enter these "non-valid-date" values as AutoSearch values in the
designer, then change tabs, I first get an error that the SQL dates are not
correct and I should review the SQL tab to determine the cause of the error.
If I do, the SQL is incomplete and the WHERE clause contains nothing where
the dates should be. That makes some sense because the GetAutoSearch...
event didn't fire while in the designer (although I wish it would so
previewing in the designer would show the same data as regular print time).
The second -- and bigger -- problem is that right up until I save the
report, the "LAST_YEAR_START" string still exists in the AutoSearch value
field in the designer. I save the report, then reopen it, and the
LAST_YEAR_START value has been replaced by todays date. Even if I don't
reopen the report and simply print it outside the designer, today's date is
used for my special string values that I want to replace. By the time
GetAutoSearch... fires at print time, the search expression is already
today's date and not the special string I entered in the designer.
1) Can I skip the error message about the SQL being wrong due to the
"invalid dates" entered in the AutoSearch criteria?
2) How can I have users enter special strings for date fields on the
AutoSearch tab, such that those special strings will be preserved and passed
to the GetAutoSearch... function where I can translate them at print time?
Thanks,
Vinnie Murdico
Our users can create reports using the end-user designer in our app. They
can set AutoSearch criteria in the designer for certain fields and if those
fields are selected for AutoSearch,we replace the SearchExpression at print
time with a "currently selected value" from our application. It works great
for four key string fields we have in our app.
But we now also want to provide similar functionality for dates. For
example, the user selects a date field as an AutoSearch field, selects >= as
the operator and then enters "LAST_YEAR_START" in the value field. I then
want our app to detect the value of "LAST_YEAR_START" in the
SearchExpression at runtime and translate it to last year's starting date.
I would like to do this with other "defined" date values as well such as
LAST_MONTH_START, LAST_MONTH_END, etc.
But when I enter these "non-valid-date" values as AutoSearch values in the
designer, then change tabs, I first get an error that the SQL dates are not
correct and I should review the SQL tab to determine the cause of the error.
If I do, the SQL is incomplete and the WHERE clause contains nothing where
the dates should be. That makes some sense because the GetAutoSearch...
event didn't fire while in the designer (although I wish it would so
previewing in the designer would show the same data as regular print time).
The second -- and bigger -- problem is that right up until I save the
report, the "LAST_YEAR_START" string still exists in the AutoSearch value
field in the designer. I save the report, then reopen it, and the
LAST_YEAR_START value has been replaced by todays date. Even if I don't
reopen the report and simply print it outside the designer, today's date is
used for my special string values that I want to replace. By the time
GetAutoSearch... fires at print time, the search expression is already
today's date and not the special string I entered in the designer.
1) Can I skip the error message about the SQL being wrong due to the
"invalid dates" entered in the AutoSearch criteria?
2) How can I have users enter special strings for date fields on the
AutoSearch tab, such that those special strings will be preserved and passed
to the GetAutoSearch... function where I can translate them at print time?
Thanks,
Vinnie Murdico
This discussion has been closed.
Comments
You will need to change the ReportBuilder source to do this. Since you are
using this feature at run-time, you should be able to get away with changing
the source without having to rebuild all the ReportBuilder packages. Check
out the TppAutosearchPanel.ValidateValue routine for a starting place to
alter the source. This method is used to show an error when the date format
is incorrect and can be found in the ppASCtrl.pas file in the
\Rbuilder\Source\... directory.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
are
changing
Check
format
Will this solve only the warning message issue or is ValidateValue also
responsible for changing my custom strings to today's date when saving the
report?
Thanks,
--
Vinnie Murdico
Software with Brains, Inc.
http://www.softwarewithbrains.com
By changing the ValidateValue routine, you will only be affecting the
Warning Message.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Ok, so how would I get RB to save whatever is typed into the AutoSearch
field when the report is saved? Right now, if I type a string that is not a
date, it converts it to today's date.
Thanks,
Vinnie
An Autosearch field is converted to a give data type in the
TppAutoSearchField.FormatValue function located in the ppASField.pas file.
You could change this source as well to save down the string entered by the
user before it is formatted into a standard date.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com