Page 1 of 1

Conditional formatting in Base form?

PostPosted: Wed Jul 06, 2016 9:40 pm
by ebrenna
Is it possible with conditional formatting when using a form in OpenOffice Base? I am making a task manager and when the deadline is coming up I'd like to highlite the post with a shiny red colour. I guess we need to make a macro? Or is there another way?

Re: Conditional formatting in Base form?

PostPosted: Thu Jul 07, 2016 12:18 am
by Villeroy
No, it is not possible. A macro can do the trick for a single-record form but not for a form grid because you can not format the rows individually.
It is possible to apply conditional formatting to a spreadsheet report.
[Tutorial] Using registered datasources in Calc

Re: Conditional formatting in Base form?

PostPosted: Thu Jul 07, 2016 1:50 pm
by ebrenna
Thanks. It is ok that it doesn't show in the report. I can sort the data there by priority anyway. So if it is possible in a single form it is good enough for me.

I am trying to make (find and copy) a macro now, but it is difficult, as I am not skilled enough to make one myself.

Re: Conditional formatting in Base form?

PostPosted: Thu Jul 07, 2016 2:30 pm
by Villeroy
Forget macro programming. Use filters to show the records you are interested in. Or combine 2 form grids side by side with different record sets. Or use sorting. If it has to be highlighted instead of selected, then use a linked database range on a spreadsheet with conditional formatting.

Re: Conditional formatting in Base form?

PostPosted: Thu Jul 07, 2016 3:40 pm
by ebrenna
Code: Select all   Expand viewCollapse view
Sub toggleColor(oEv)
REM get model of calling button:
oModel = oEv.Source.getModel()
nColor = oModel.BackgroundColor
if Red(nColor) = 0 then
   nNew = RGB(255,0,0)
else
   nNew = RGB(0,255,0)
endif
oModel.BackgroundColor = nNew
End Sub


I have used this code to create a button that changes color (on and off). My goal is (was) to use this button to both show clearly to the user (me) that this issue is prioritized ("Prioritert" in Norwegian") and let the button replace the small checkbox you can see above it.

Image

But if it is impossible to add the same data to the database with the button as with the checkbox, I guess I instead have to use the methods you have already explained to me.

If there is nothing else to add to this topic, I thank you for your help.

Re: Conditional formatting in Base form?

PostPosted: Fri Jul 08, 2016 1:17 pm
by F3K Total
Hello,
find attached an example. The only way i found, to format a formatted field column in a tablecontrol conditionaly.
R

Re: Conditional formatting in Base form?

PostPosted: Fri Jul 08, 2016 4:25 pm
by ebrenna
Thanks, that works in tables showing data in form view. Very good, I needed that function. :D

How I did this, after looking at your example:
In edit mode I right clicked the upper part of the table at a vacant spot and added a new column. Right clicking the new column, add new, formatted, then right click the new column and choose "Column...". Under the Data tab choose the desired field from your database. Under general edit the name and label as you wish, then click [...] next to Formatting and enter the conditional formatting you like:

Code: Select all   Expand viewCollapse view
[<=3][RED]General;[<10][BLUE]General;General


For the check box column I changed this into:
Code: Select all   Expand viewCollapse view
[=1][RED]General;[=0][GREEN]General;General

Note that I had to change language from Norwegian to English (USA) to make it understand the word "General" in the code. But I realized that replacing "General" with "Standard" (in my language) made it work without changing the language.

So it works, and I guess the code can have a large number of variables. In my edited code 1 gives red and General text (standard text?), 0 gives green text, and other numbers gives normal, standard text formatting.

I was not able to apply the same trick to the button color automatically by reading the data in the database, but I already have code to make it change color.

The next question is if it is possible with conditional formatting also in the generated report...? I'll let you know it I find a solution, but can manage without the report, really. Still, it was annoying with the extremely small check boxes in the report... :?

Thanks so far.

Re: Conditional formatting in Base form?

PostPosted: Fri Jul 08, 2016 4:49 pm
by F3K Total
Hi,
with the shipped report-Builder it's not possible, but with the Oracle-Report-Builder Extension, conditional formatting can be done.
R

Re: Conditional formatting in Base form?

PostPosted: Fri Jul 08, 2016 6:31 pm
by ebrenna
Thanks. I installed it, and can see that this gives me more options. I couldn't find where I can add conditional formatting, but I will look more into it later. If you give me a hint, I will appreciate it very much.

Re: Conditional formatting in Base form?

PostPosted: Fri Jul 08, 2016 6:37 pm
by F3K Total
Hi,
in Edit Mode, select a control and then Menue Format/Conditional Formatting...
R

Re: Conditional formatting in Base form?

PostPosted: Fri Jul 08, 2016 6:41 pm
by ebrenna
No menus are visible, for some reason. No toolbars, nothing. I can only see this:

Screen_OpenOfficeBase2.PNG

Re: Conditional formatting in Base form?

PostPosted: Sat Jul 09, 2016 9:24 am
by charlie.it
ebrenna wrote:No menus are visible, for some reason. No toolbars, nothing. I can only see this


For this reason I use Libre Office with reports.