[Solved] I need to auto set...and than sort by its result

Discuss the database features
Post Reply
JadianRadiator
Posts: 5
Joined: Mon Nov 26, 2018 7:38 pm

[Solved] I need to auto set...and than sort by its result

Post by JadianRadiator »

This is all for a list that sorts entered download info from smallest to biggest.
I need to make a query or something for OpenOffice Base that reads two fields,
does math on the first one depending on what the second one is set to,
and then writes the result to a third field.
The first field is a data size, without the measurement label.
The second field is the measurement label.
Such as "KB" for kilabyte, "MB" for megabyte, and "GB" for gigabyte.
The math I need is to convert the size number down to kilabytes,
and then write that value to the third field.
I've come up with something for it in OpenOffice's spreadsheets "Calc", which I have attached the template for it.
But I am wanting to swap over to using OpenOffice Base.
As I believe it would allow for a more robust and better made list.
I searched for it on the forum.
Found this thread.
viewtopic.php?f=13&t=14396&p=67760&hili ... eld#p67760
From there, I went to the wiki here.
https://www.openoffice.org/documentation/
Closest thing to what I'm needing was this documentation.
https://wiki.openoffice.org/wiki/Docume ... Wiki_Books
And the documentation on that page isn't a dev manual nor reference.
Attachments
Download Order.ots
Bit of an issue with the .odb provided
(25.45 KiB) Downloaded 179 times
Last edited by JadianRadiator on Sat May 02, 2020 5:46 pm, edited 3 times in total.
Apache OpenOffice 4.1.5
Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: I need to auto set...and than sort by its result

Post by Villeroy »

Quick draft.
Attachments
SizeUnits.odb
Calculate GB,MB,KB
(13.23 KiB) Downloaded 182 times
Last edited by Villeroy on Sat May 02, 2020 8:21 pm, edited 4 times in total.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JadianRadiator
Posts: 5
Joined: Mon Nov 26, 2018 7:38 pm

Re: [Solved] I need to auto set...and than sort by its resul

Post by JadianRadiator »

thankyou very much!
Apache OpenOffice 4.1.5
Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] I need to auto set...and than sort by its resul

Post by Villeroy »

I see that you use a template for one(?) download order and that you may want to save lots of download orders in a database, right?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JadianRadiator
Posts: 5
Joined: Mon Nov 26, 2018 7:38 pm

Re: [Solved] I need to auto set...and than sort by its resul

Post by JadianRadiator »

Slight issue with your .odb's form.
The form sees the "Byte" alias.
And the form is saying that its "Byte" field requires entry when I try to move on from a field I've entered.
Still though, your odb is awesome.
Thankyou again!
Apache OpenOffice 4.1.5
Windows 10
JadianRadiator
Posts: 5
Joined: Mon Nov 26, 2018 7:38 pm

Re: I need to auto set...and than sort by its result

Post by JadianRadiator »

Giving it a default value fixed it.
Again, thankyou very much!
Apache OpenOffice 4.1.5
Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] I need to auto set...and than sort by its resul

Post by Villeroy »

Thank you. I wonder why I did not notice this issue. Open the form for editing (right-click>Edit).
Right-click the column header "Byte" and choose "Column... ", select the "Data" tab. "Input required" = No
 Edit: I replaced my file with the fixed version. And added an ORDER BY clause to the query 
The "Byte" value is not stored in the database. It is calculated from the stored values for size and unit. The form's underlying record set is "Query1" which goes like this:

Code: Select all

SELECT "DLOrder".*, 
  "SIZE" * POWER( 1024, CASE WHEN "UNIT" = 'GB' THEN 3 WHEN "UNIT" = 'MB' THEN 2 WHEN "UNIT" = 'KB' THEN 1 ELSE 0 END ) AS "Byte" 
FROM "DLOrder"
ORDER BY "Byte" ASC
It selects all the columns from the table plus a calculated column SIZE * POWER(1024, 3|2|1|0). The calculated column is not writable anyway, so it should not be marked as "entry required" in the form.
The ORDER BY clause in the query enforces the given sort order. Without that clause you can sort in the form.
You may also save a sort order for the form which can be overridden. Open form in edit mode, right click>Form... tab "Data", "Sort order" defines a preset sort order.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply