I have formatted fields in a table grid on a form for latitude and longitude, expressed to two decimal places. When I have a value of (e.g.) “3.00” (= 3 degrees east exactly) I cannot make the display show “3.00”. When I set the format to “0.00” (which I understand to force this) the display still reverts to “3”. Any advice welcome!
Normally one works on the forms applied to the tables. On forms, it is easy to format the data as you wish.
Yes, but as explained, I apply the format and it takes no notice!
Without a concrete example of your database it is difficult to help you.
Does this answer the question - or are we about to start confusing discussion threads without any distinction of comments and answers?
This is the appearance of the table. Note that under the Latitude and Longitude fields, I wish there always to be two decimal places shown, so that the decimal point remains aligned.
Displayed below are the properties of the Longitude column, showing the number format which should produce the desired result, but does not do so.
Format for a number seems to be right. Have tested it and it works: Database with table control in a form an 2 decimal places
Thank you, RobertG, for your sample, which works perfectly. Having created an entirely new sample database for myself, I have also demonstrated correct function. But - incomprehensibly - it does NOT work for the example I submitted. I tried designing a new form based on the same data, and had the same problem: that if the ‘Longitude’ field is defined (in the table grid) as a ‘formatted field’, the formatting instruction is simply ignored.
I guess therefore that the problem lies with the table structure. The db tables are not embedded in LibreOffice, but are held in an SQLite database. There must be something to do with the ODBC connection that is producing this curious behaviour. (Those fields are defined in SQLite as ‘Decimal (3,2)’ but read by LibreOffice as ‘Text [VarChar]’.)
I can resolve the problem by changing the relevant columns to ‘Numeric fields’ - but that may throw up other issues (such as reporting blanks as ‘0.00’) which I have not yet identified and which may not be trivial. I shall leave this open for a few days before marking it as ‘solved’, in case anyone else has a useful comment to make.
Apologies if I have not handled the new format of this forum correctly!
When having a look on SQLite datatype I would create such a column as NUMERIC or FLOAT. Both will be automatically save all decimal places I wish. This will be also supported by LO connecting through ODBC.
Seems something like “Decimal(3,2)” isn’t supported through ODBC.
You could try to CAST(“Lat” AS NUMERIC) in a query to get it as a numeric value.
I would need the database, if possible, to try to operate directly. The images don’t help that much …
Thank you, RobertG, for that precious insight! I changed the field type in the SQLite database from “DECIMAL(3,2)” to “NUMERIC(3,2)” and now, without any other changes, LibreOffice reads those fields as “Double[Double]” and the formatting behaves as it should.
Way beyond my pay grade (none) to understand, but another useful tip!