Macro code similar to MS Access

Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This section is not for asking questions about writing your own macros.
Post Reply
longi
Posts: 110
Joined: Mon Jul 15, 2013 5:04 pm

Macro code similar to MS Access

Post by longi »

Hello!

First of all, I have to apologize about my English.
Secondly I have to apologize about the code.
I tried lots of times to get an Access simulation, without good results. The code here shown gets most of things I wanted. However, I tried to get a key combination for all forms you have in your database, so, I changed a bit the code, in order to have a wider use. (I put a button to launch the macro, but everyone is free to use the key combination that they want.)
The second thing is that I wanted to use it in all kind of controls at the same time, including subforms, so we have to avoid the use of the event.
I use an UnklDonald418’s macro to sail through all forms, subforms and controls, then I use the Arineckaig’s code for ‘normal controls’ and for ‘table controls’.
I’m conscious that something (or all) is wrong ( especially about ‘table controls’, in which it seems working, but the macro has to run through all controls several times).
It is possible to fix this code (my mess code) a bit?
Attachments
CONTROL X4.rar
(22.1 KiB) Downloaded 280 times
OpenOffice 4.1.5 on Windows 10
LibreOffice 5.1 on Windows 7
LibreOffice 6.0.1 on Windows10
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Base Copy Field or Clone Record - Example

Post by UnklDonald418 »

longi
The code you copied from my post recursively searches the Form Document for all the table controls. I was trying to use hasFocus() to determine which table to use when copying the data. Unfortunately, once a single grid element on a table is chosen hasFocus() always returns False.
By using an event Arineckaig's elegant code establishes which table to use without searching. The drawback is that each table must have an event defined for the macro to work on it. One of my original goals was to avoid having to use an event, but that appears to be impossible.
The bottom line is that by placing his code inside my recursive code you are attempting to copy data on every table on the Form Document.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Macro code similar to MS Access

Post by acknak »

Split to new topic. Originally here: viewtopic.php?f=21&t=83531

I had to guess at a title. Please change it or let me know if it should be changed.
AOO4/LO5 • Linux • Fedora 23
Post Reply