Date: prev next · Thread: first prev next last
2024 Archives by date, by thread · List index


Hi Edwin,

I need to copy the first word from an existing field and place it into a new field. Is there a way to do that autoagically?

Only per macro:

1. Connect to the field in your form.
2. Read value from this field
3. Split content into an array
4. Take first entry of this array and put it to the new field.

But: You won't need the new field if you only want to extract the first word and won't edit the new field. You could also get the first word by SQL:

SELECT "Sentence", LEFT("Sentence", POSITION(' ' IN "Sentence")) AS "FirstWord" FROM "Table"

If there is only one word in "Sentence" this word wouldn't be shown. So the code has to be expanded:

SELECT "Sentence", CASE WHEN POSITION(' ' IN "Sentence") > 0 THEN LEFT("Sentence", POSITION(' ' IN "Sentence")) ELSE "Sentence" END AS "FirstWord" FROM "Table"

Regards

Robert
--
Homepage: https://www.familiegrosskopf.de/robert


--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.