Page 1 of 1

[Solved] Calc sheet column like ID in database

Posted: Sun Jun 09, 2024 3:22 pm
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

Re: Calc Sheet column like ID in database

Posted: Sun Jun 09, 2024 4:04 pm
by Villeroy
You could simply use a relational database.

Re: Calc Sheet column like ID in database

Posted: Sun Jun 09, 2024 6:26 pm
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

Re: Calc Sheet column like ID in database

Posted: Sun Jun 09, 2024 6:55 pm
by Villeroy
A million lines of silly Basic code can not turn water into wine.

Re: Calc Sheet column like ID in database

Posted: Mon Jun 10, 2024 12:52 am
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.

Re: Calc Sheet column like ID in database

Posted: Mon Jun 10, 2024 4:33 pm
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