Page 1 of 1

Conditional formatting?

PostPosted: Sun Nov 12, 2017 9:49 pm
by MSPhobe
Suppose I have a query producing...

Goblet of Fire
Moby Dick
-- Rockwell illustrations
Seven Pillars of Wisdom
The Hobbitt
-- Second edition
The Spire
Winnie-The-Pooh
Yearling
-- Pristine dust jacket


(Which I do!)... (See viewtopic.php?f=42&t=91167% for how that was done.)

The query scans a table with a book inventory. The table has "Title" and "Comment" fields. The query always produces a line in it's output table for every title. It also, but only when there is something in the Comment field, it produces a line with the comment, pre-fixed with '--' (Which is not anything to do with using "--" to put a comment in some SQL... it just seemed a good idea at the time as a way to distinguish a comment line.

So... according to the sample above, there is nothing in the Comment field for the Goblet of Fire record, but ther IS ("Rocwell Rockwell illustrations") for the Moby Dick record.

Whew! That's the context.

I'm hoping someone can help me do...

I want a report with the title names in one style (font-name/ size/ color, etc), and the comment lines (if any) in a different style.

Maybe the "--" at the start of each line helps... of maybe not, maybe a completely different approach is needed?

I'm hoping all this can be done under OO 4.1.1, using the embedded HSQL engine. (Apologies.. earlier that said "4.4.1"... checked it TWICE, still got it wrong!)

Re: Conditional formatting?

PostPosted: Sun Nov 12, 2017 10:13 pm
by Villeroy
1. A Writer document (a serial letter) with database fields combined with conditional fields can do the trick without the nasty UNION query.
2. A Calc spreadsheet can do conditional formatting. All my reports are Calc sheets.

Re: Conditional formatting?

PostPosted: Sun Nov 12, 2017 10:58 pm
by MSPhobe
Can either (both?!) meet my want of not having blank lines where there is no comment, please?

Re: Conditional formatting?

PostPosted: Mon Nov 13, 2017 1:17 am
by Villeroy
1. Yes. http://freesoftwaremagazine.com/article ... ffice_org/ (figure 3: hiding blank lines)
2. Define the query so it does not include any blank values nor empty strings. Calc can do that too.

Re: Conditional formatting?

PostPosted: Mon Nov 13, 2017 2:26 am
by chrisb
MSPhobe,
the Report Builder extension supports conditional formatting.
i do not know whether you are familiar with Report Builder so i have uploaded an attachment in order to avoid any issues.

when the report is opened in edit mode then the necessary formatting is easily achieved by:-
1. select the text box to be formatted (TitlePlusComment).
2. menu:Format>Conditional Formatting.
3. as each of our 'Comments' is preceded by '--' i have used the expression 'LEFT([TitlePlusComment];2)="--"'.
when the expression is true then the field will be formatted in accordance with the selected options (six icons 'B', 'I', 'U' etc.).

other forum users have suggested alternative solutions. i am simply responding to the issue as stated which may/may not be the best option. you must decide.
Books.odb
(23.84 KiB) Downloaded 86 times

Re: Conditional formatting?

PostPosted: Mon Nov 13, 2017 12:01 pm
by longi
Hi!

If you are not using ORB you can get similar results, but using code (which could bother you )
Here you have several examples:

https://forum.openoffice.org/es/forum/viewtopic.php?f=70&t=11605

If only you want the conditional formatting, it's better you use the ORB extension.

Bye!