Topic: weird behavior

In a project made with MVD 6.1, I see strange behavior. (See illustration in attachment).
The column concerned is the result of a calculated field (Type Currency).
For certain values, the display is correct (ie 10113.58), for others there are too many digits after the decimal places (ie 96931.229999999).
I had the same display problem but in a report. A tip from Derek had saved my day and fixed the problem.
This time it doesn't work.
On the other hand, the value of the footer of this column is displayed correctly.

Here is the part of the code that applies to this column:

Recipes := Form1.TableGrid1.Columns[5].Footer.FormulaValue;
Expenses := Form1.TableGrid1.Columns[4].Footer.FormulaValue;
Balance := (Form1.TableGrid1.Columns[6].Footer.FormulaValue)- (Form1.TableGrid1.Columns[5].Footer.FormulaValue);
Form1.Edit1.Text:= FormatFloat('00.00',Balance)+ ' €';
Form1.TableGrid1.Columns[7].Footer.Caption := FormatFloat('00.00',Balance).

Thank you if anyone can resolve this anomaly which must be insignificant.
Thanks in advance.

JB

Post's attachments

Attachment icon Example.jpg 14.52 kb, 11 downloads since 2024-01-05 

2 (edited by sparrow 2024-01-05 21:02:31)

Re: weird behavior

The simplest solution in a calculated field is to use the SQLITE function ROUND (,)


Show the code of the calculated field or, better yet, an example of a table in the example program.

Re: weird behavior

Hello Sparrow

Thank you for your answer.
In fact, I was using the Round function, but I was applying it to the wrong column which was already in the right format.
But you opened my eyes.
Another question independent of this one, if I may ask you again.
I have a TableGrid with CheckBox and with Multiselect option.
Is it possible to select several rows and save these rows in a text file?
In order to purify this grid of lines which have become obsolete.
Thanks in advance
Sincerely
J.B.

Re: weird behavior

Salut Jean,
Attached is an old project that I made a couple of changes to and wondered if it might give you some ideas.
Basically,
1.  you tick whichever records you want to purge using the tablegrid check-box.
2.  tick the 'filter' check-box (as a way to confirm you are happy with your selections)
3a.  if you are not happy, just untick the 'filter' check-box and start again.
3b.  if you are happy, click the 'purge' button - this copies the selected records to a spreadsheet and then deletes them from the table.
I appreciate you wanted something that wrote to a text file but perhaps you can just modify this (or maybe writing to a spreadsheet is okay).
Another way might be to simply 'logically delete' checked records with a 'flag' (which always gives you the luxury of retrieving something that you might have deleted in error).  This would probably be my preferred option but obviously I don't know what your exact requirements are in this instance.
Anyway, hope it helps a bit.
Regards,
Derek.

Post's attachments

Attachment icon checkbox as filter 1.zip 466.79 kb, 39 downloads since 2024-01-06 

Re: weird behavior

Hello Derek
Perfect code that does the job exactly.
Before the Excel sheet appears, I will place a SaveDialog
allowing the user to enter the folder of their choice (although they can do so from the Excel menus (Open -> Save As...).
But as people like to be served dishes without having to go to the buffet...
Very nice your answer
Sincerely
J.B.