
Quote from vwatson on January 15, 2020, 7:42 amI created a report in Report Designer with a repeating body. It's working fine, except I'd like to alter the content of one of the db fields before it's printed. Is that possible?
The database contains a text field with a separator character. When I print it, I'd rather have that character removed, but I don't see any way to do that in the Report Designer.
What I need to do is something like attaching a function to the text field to alter the content and return the changed text to the report builder.
Would a dbpExecSQL command work for this?
I created a report in Report Designer with a repeating body. It's working fine, except I'd like to alter the content of one of the db fields before it's printed. Is that possible?
The database contains a text field with a separator character. When I print it, I'd rather have that character removed, but I don't see any way to do that in the Report Designer.
What I need to do is something like attaching a function to the text field to alter the content and return the changed text to the report builder.
Would a dbpExecSQL command work for this?
Quote from Gaev on January 16, 2020, 4:42 am@vwatson
I would suggest a simplistic (but Brute Force) solution ...
a) create an additional field/column ... say the original field is called Category ... say you call this new field CategoryPrinted
b) before running the report, update the CategoryPrinted field using the Category field ...
dbpOpenTable "yourID" "yourTable" "" ... if your report is on a filtered set of records dbpQuery "yourID" "yourTable" "yourFilter" Loop "1" "[yourID.yourTable.$RecCount]" "[junk]" StrReplace ""[yourID.yourTable.Category]" "!yourSeparatorCharacterHere" "" "[yourID.yourTable.CategoryPrinted]" "" dbpNext "yourID" "yourTable" EndLoopWould a dbpExecSQL command work for this?
This web page ... https://www.sqltutorial.org/sql-string-functions/sql-replace/ ... shows you how to use an SQL command.
If it still takes too long to cycle through the filtered records, you could do something like ...
UPDATE yourTable SET CategoryPrinted = REPLACE(Category,'separatorCharacter','');... with an (optional) WHERE clause to filter only those records that would be used in the Report.
I would suggest a simplistic (but Brute Force) solution ...
a) create an additional field/column ... say the original field is called Category ... say you call this new field CategoryPrinted
b) before running the report, update the CategoryPrinted field using the Category field ...
dbpOpenTable "yourID" "yourTable" "" ... if your report is on a filtered set of records dbpQuery "yourID" "yourTable" "yourFilter" Loop "1" "[yourID.yourTable.$RecCount]" "[junk]" StrReplace ""[yourID.yourTable.Category]" "!yourSeparatorCharacterHere" "" "[yourID.yourTable.CategoryPrinted]" "" dbpNext "yourID" "yourTable" EndLoop
Would a dbpExecSQL command work for this?
This web page ... https://www.sqltutorial.org/sql-string-functions/sql-replace/ ... shows you how to use an SQL command.
If it still takes too long to cycle through the filtered records, you could do something like ...
UPDATE yourTable SET CategoryPrinted = REPLACE(Category,'separatorCharacter','');
... with an (optional) WHERE clause to filter only those records that would be used in the Report.

