[Base] Customize an error message

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
jeanmi2403
Posts: 29
Joined: Tue Jan 29, 2008 12:37 pm
Location: Sucy en Brie (France)

[Base] Customize an error message

Post by jeanmi2403 »

Hello,
I have a database with a field built as a unique index. When a user tries to create a record with an existing value for this field in the database, he gets this message:
MessageUnique.PNG
MessageUnique.PNG (27.44 KiB) Viewed 967 times
I would like to be able to intercept the error in order to display a more sympathetic and "clearer" message.
Is this possible?
I think i have to use a Listener, I don't know how to implement it.
Sincerely,
Jean-Michel
LibO 7.4.7 and AOO 4.1.14 on Windows 10 x64, Windows 11 & Ubuntu 22.04
LibO 7.5 on OpenSuse & Linux MX
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Base]Customize an error message.

Post by Villeroy »

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
User avatar
jeanmi2403
Posts: 29
Joined: Tue Jan 29, 2008 12:37 pm
Location: Sucy en Brie (France)

Re: [Base]Customize an error message.

Post by jeanmi2403 »

Hello,
I am shortsighted !
Moreover, it was I who translated the Base Guide into French...
I'm ashamed
but it doesn't work for this error..
Jean-Michel
LibO 7.4.7 and AOO 4.1.14 on Windows 10 x64, Windows 11 & Ubuntu 22.04
LibO 7.5 on OpenSuse & Linux MX
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Base]Customize an error message.

Post by Villeroy »

jeanmi2403 wrote: Wed Jan 25, 2023 12:39 am Hello,
but it doesn't work for this error..
Open the form in the attached file and enter a duplicate. You get the msgbox defined in my macro titled "Macro: SQL Error"
Attachments
index_violation.odb
(12.38 KiB) Downloaded 51 times
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
User avatar
jeanmi2403
Posts: 29
Joined: Tue Jan 29, 2008 12:37 pm
Location: Sucy en Brie (France)

Re: [Base] Customize an error message

Post by jeanmi2403 »

Very myopic! I hadn't seen the title of the message box.
I had simply noticed that the message was the same.
 Edit: But it works only if the field is a primary key.
Unique constraint on an other field do not work, the macro is not executed and the original message is displayed 
Thank you very much.
Jean-Michel
LibO 7.4.7 and AOO 4.1.14 on Windows 10 x64, Windows 11 & Ubuntu 22.04
LibO 7.5 on OpenSuse & Linux MX
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Base] Customize an error message

Post by Villeroy »

My personal work-around that has been proven as good enough: Give a talking name in upper case letters to the index, so the original error message includes a not so hidden human message like "PLEASE_ENTER_UNIQUE_NAME"
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
User avatar
jeanmi2403
Posts: 29
Joined: Tue Jan 29, 2008 12:37 pm
Location: Sucy en Brie (France)

Re: [Base] Customize an error message

Post by jeanmi2403 »

Ok, crafty !!
Thanks
Jean-Michel
LibO 7.4.7 and AOO 4.1.14 on Windows 10 x64, Windows 11 & Ubuntu 22.04
LibO 7.5 on OpenSuse & Linux MX
Post Reply