[Solved] Calc sheet column like ID in database

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
nickGiard
Posts: 24
Joined: Fri Nov 10, 2017 5:57 pm

[Solved] Calc sheet column like ID in database

Post by nickGiard »

It is possible, with macro, to make a Calc column that contains integer numbers like ID in data base, where the rows are like records?
If User change that ID, the old ID is resumed when he does an event.
If User duplicate one row, new ID is write in new row when he does an event.
If User erase one row, that ID will be never used, it is lost.
If User insert one row, the previous IDs do not change, new ID is write in new row when he does an event.
This is useful to make separate tables like relational data base.
:shock:
Thank you
Nick
Last edited by MrProgrammer on Thu Jul 04, 2024 6:49 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] Suggestions provided -- MrProgrammer, forum moderator
LibreOffice 6.3 on Windows 10 64bit
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc Sheet column like ID in database

Post by Villeroy »

You could simply use a relational database.
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
nickGiard
Posts: 24
Joined: Fri Nov 10, 2017 5:57 pm

Re: Calc Sheet column like ID in database

Post by nickGiard »

Thank you Villeroy, it's very true :D :D
but my life develop :crazy: :crazy: has been a spreadsheet software (40'000 code rows) for architects or engineers for estimate buildings cost, all other commercial solutions are in relational database.
The question is also for abstraction and brain and resolve a particular problem...
Any idea ? ( my Italian society is Helpidea S.r.l. :D :D )
By
LibreOffice 6.3 on Windows 10 64bit
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc Sheet column like ID in database

Post by Villeroy »

A million lines of silly Basic code can not turn water into wine.
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
JeJe
Volunteer
Posts: 3068
Joined: Wed Mar 09, 2016 2:40 pm

Re: Calc Sheet column like ID in database

Post by JeJe »

You can control what happens when someone, say deletes a row, by providing a toolbar button to do it. Another button to insert an item. As you don't want to resuse IDs you just need a counter storing the last ID which could be in a cell or a document property to increment by 1 for the next ID.

This forum is to help people write their code, not to do it for you, so if you make a start people can help you with your coding when you get stuck.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
nickGiard
Posts: 24
Joined: Fri Nov 10, 2017 5:57 pm

Re: Calc Sheet column like ID in database

Post by nickGiard »

Villeroy wrote: Sun Jun 09, 2024 6:55 pm A million lines of silly Basic code can not turn water into wine.
Thank you Villeroy, it's very true :D :D , but sometimes can turn idea in a brilliant idea :D :D
Thank you JeJe, the idea to put buttons for control events on rows may be good, but for me the event like double click on the row, is after.
I don't ask to forum to write code for me, but only think about a problem, e share develop ideas. I'm wrong??
Nick
LibreOffice 6.3 on Windows 10 64bit
Locked