Base: Form events not being called
Base: Form events not being called
I'm trying to write macros to automate a few procedures in Base, but am finding difficulty in understanding the actions which produce some of the events.
Firstly, when I fire up the form from the Edit window, the Loading events don't seem to happen. Nor do the Reset events. So I can't work out how to initialise anything that I may need. What does happen, though, is that the "Before record change" event happens twice.
Secondly, the "record action" events never fire, whatever I do to the current record. So it's not easy to see how to detect changes to the record.
If it makes any difference, the form has a subform which displays a query which populates the fields of the main form on selecting a record. Changing the selection sparks off the "record change" events so in theory I can detect changes that way, but it's not madly satisfactory. Any idea how to get the missing events to happen?
Firstly, when I fire up the form from the Edit window, the Loading events don't seem to happen. Nor do the Reset events. So I can't work out how to initialise anything that I may need. What does happen, though, is that the "Before record change" event happens twice.
Secondly, the "record action" events never fire, whatever I do to the current record. So it's not easy to see how to detect changes to the record.
If it makes any difference, the form has a subform which displays a query which populates the fields of the main form on selecting a record. Changing the selection sparks off the "record change" events so in theory I can detect changes that way, but it's not madly satisfactory. Any idea how to get the missing events to happen?
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Hello
I think use a higher version then you do now.
Romke
I think use a higher version then you do now.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
How does that help me? Or were there known bugs in my version which aren't in the latest?
I tried Libre Office a few weeks ago - it trashed my database.
I tried Libre Office a few weeks ago - it trashed my database.
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Hello
I don't know on this moment the version numbers but there where some version who did not work correct. The version numbers differ a little between OOo en LibO. I do use on this moment LibO 3.4.5 and it is the stable version of openSUSE.
When you use LibO then use a version with a 5 a last number that are real stable version. Version with 1 and 2 can have bugs. This is not my opinion but from the makers of LibO.
Now the event
There is an event what is fired two times select the service you need. You must adjust the code to your needs
When you use a gridcontrol then some events work for the grid and other work for the controls in the grid. My experience was that it change in the different version. You see it more often in OOo that when they are working on some part of the program you can have problems. They are working for OOo-base and you sometime bugs.
When you are interest in macros then you can look to the examples I did place in the forum for examples but I'm not a real programmer but a home user.
Romke
I don't know on this moment the version numbers but there where some version who did not work correct. The version numbers differ a little between OOo en LibO. I do use on this moment LibO 3.4.5 and it is the stable version of openSUSE.
When you use LibO then use a version with a 5 a last number that are real stable version. Version with 1 and 2 can have bugs. This is not my opinion but from the makers of LibO.
Now the event
There is an event what is fired two times select the service you need.
Code: Select all
sub BeforeRecordChange(oEvent as object)
dim oForm
select case oEvent.Source.implementationname
case "com.sun.star.form.FmXFormController" : oForm= oEvent.Source.model
case "com.sun.star.comp.forms.ODatabaseForm"
oForm= oEvent.Source
print oForm.implementationname,oForm.ismodified
case "org.openoffice.comp.svx.FormController" : oForm= oEvent.Source.model
case else print oEvent.Source.implementationname
end select
End Sub
When you use a gridcontrol then some events work for the grid and other work for the controls in the grid. My experience was that it change in the different version. You see it more often in OOo that when they are working on some part of the program you can have problems. They are working for OOo-base and you sometime bugs.
When you are interest in macros then you can look to the examples I did place in the forum for examples but I'm not a real programmer but a home user.
I think a sub form should not change a mainform but maybe I'm wrong.ptoye wrote: If it makes any difference, the form has a subform which displays a query which populates the fields of the main form on selecting a record. Changing the selection sparks off the "record change" events so in theory I can detect changes that way, but it's not madly satisfactory. Any idea how to get the missing events to happen?
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
Hello
A little more about selecting the service you need. Most of the time you have a choice of two services.
a) one is pointing to the view of the form
b) One is pointing to the model of the form.
Case a is the most unclear there we are not often work with it. But I have the idea it can be helpfull in some cases.
In this you find an explanation why this interface can be important. Lower you can see some methods who can be helpfull.
Romke
A little more about selecting the service you need. Most of the time you have a choice of two services.
a) one is pointing to the view of the form
b) One is pointing to the model of the form.
Case a is the most unclear there we are not often work with it. But I have the idea it can be helpfull in some cases.
In this you find an explanation why this interface can be important. Lower you can see some methods who can be helpfull.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
Thanks very much for all this - looks very interesting. And takes some time to digest (why is the OO API documentation so opaque, or is it just me?).
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Hello
The API of OOo is real difficult. First people have to understand how they can work with OOo. Solving the same problem in OOo difer from the method how to do in MSO. Some people think macros is the solution for a problem. Those macros make it most of the time more difficult.
When you work good with OOo and want work with macros then you need to understand the API and the services and interfaces exported by the different objects. Understanding the API means you knew how you go from one object to an other object. This understanding you can only learn by working with the API and make code what works.
Some people think we can explain to them how it is working. Some teaching can speed up the work but you must also learn working with the code and then the understanding is growing.
Try to read in the forum for tutorials how you can work with OOo. There you can find good explanations with examples.
Romke
The API of OOo is real difficult. First people have to understand how they can work with OOo. Solving the same problem in OOo difer from the method how to do in MSO. Some people think macros is the solution for a problem. Those macros make it most of the time more difficult.
When you work good with OOo and want work with macros then you need to understand the API and the services and interfaces exported by the different objects. Understanding the API means you knew how you go from one object to an other object. This understanding you can only learn by working with the API and make code what works.
Some people think we can explain to them how it is working. Some teaching can speed up the work but you must also learn working with the code and then the understanding is growing.
Try to read in the forum for tutorials how you can work with OOo. There you can find good explanations with examples.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
Hello
In this two threads you can read you are not the only one with problems.
http://user.services.openoffice.org/en/ ... 76#p221264
http://user.services.openoffice.org/en/ ... 20&t=46549
Romke
In this two threads you can read you are not the only one with problems.
http://user.services.openoffice.org/en/ ... 76#p221264
http://user.services.openoffice.org/en/ ... 20&t=46549
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
I have exactly this problem - the learning curve for the OO API is just far too long to make it worth while learning. As a retired programmer, I'm used to being able to pick up the book, read it, and start work. Comments like "it took me 2 years" make it plain that I need whatever the API designers were smoking. In industrial (and probably illegal) quantity.
I'm slowly getting there, though, on the macro front. I've found that when you have a subform the main and subforms have different sets of macros. And when you save the record explicitly from the subform the "record action" macros for the subform are called. But not if you select a different record in the main form - the automatic record save isn't flagged by a record action macro call. Sounds like a bug to me.
I'll try the latest LibreOffice. And back up the database first!
I'm slowly getting there, though, on the macro front. I've found that when you have a subform the main and subforms have different sets of macros. And when you save the record explicitly from the subform the "record action" macros for the subform are called. But not if you select a different record in the main form - the automatic record save isn't flagged by a record action macro call. Sounds like a bug to me.
I'll try the latest LibreOffice. And back up the database first!
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
If you haven't already found it, the source for macro programming in OpenOffice is Andrew Pitonyak's site:
http://www.pitonyak.org/oo.php
http://www.pitonyak.org/oo.php
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Base: Form events not being called
Hello
That understanding of the API of OOo is difficult is told many times but people don't believe it most of the time. I have the idea that when you work with understanding of how OOo and the API is working then the coding can be more easy. But I have also the idea that most starters want work with OOo as if it is MSO and then the problems are growing.
An other problem is working with opensource software special when you work with OOo and now LibO. I use LibreOffice from openSUSE. The version I use maybe differ from Ubuntu and also maybe differ from the original LibreOfice. So I cannot say if a special problem is a bug in OOo or in the code of the user.
Both points make I do post more examples for code where I explain some parts and do less answer real questions.
Understanding Service and Interfaces
I do point me only on the database and then special on forms who are embedded in the database. I have study for me all the methods and properties of the service who belong to a dataform. This can also be the controls who are in a data-form. Every time I did understand a special interface who was in a form I could use more simple code. I did cost me also a long time to understand and see the difference between the model of an object and the view on an object.
Drilling up and down.
One of the nice things of the API is when you start with an event you get most of the time get all the service you need. Below an example.Before you can write such a line of code you must have an idea how all service are connect. Most of the time such line is only working in special case and not somewhere else.
Conclusion
I think for most people it is better to avoid macros even for programmers. When you want continue with macros try to understand the working of OOo and use little macros. Try to use a version what is the best version for your purpose. The best version can be differ from one person to an other person.
Romke
That understanding of the API of OOo is difficult is told many times but people don't believe it most of the time. I have the idea that when you work with understanding of how OOo and the API is working then the coding can be more easy. But I have also the idea that most starters want work with OOo as if it is MSO and then the problems are growing.
An other problem is working with opensource software special when you work with OOo and now LibO. I use LibreOffice from openSUSE. The version I use maybe differ from Ubuntu and also maybe differ from the original LibreOfice. So I cannot say if a special problem is a bug in OOo or in the code of the user.
Both points make I do post more examples for code where I explain some parts and do less answer real questions.
Understanding Service and Interfaces
I do point me only on the database and then special on forms who are embedded in the database. I have study for me all the methods and properties of the service who belong to a dataform. This can also be the controls who are in a data-form. Every time I did understand a special interface who was in a form I could use more simple code. I did cost me also a long time to understand and see the difference between the model of an object and the view on an object.
Drilling up and down.
One of the nice things of the API is when you start with an event you get most of the time get all the service you need. Below an example.
Code: Select all
oConnection=oForm.Activeconnection
oReportsDocuments=oConnection.parent.DatabaseDocument.ReportDocuments ' This point to the report containers
Conclusion
I think for most people it is better to avoid macros even for programmers. When you want continue with macros try to understand the working of OOo and use little macros. Try to use a version what is the best version for your purpose. The best version can be differ from one person to an other person.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
Interesting - when I go to the LibreOffice site, it recommends 3.5.2! This is for Windows - haven't looked for other OSs.RPG wrote:Hello
I don't know on this moment the version numbers but there where some version who did not work correct. The version numbers differ a little between OOo en LibO. I do use on this moment LibO 3.4.5 and it is the stable version of openSUSE.
When you use LibO then use a version with a 5 a last number that are real stable version. Version with 1 and 2 can have bugs. This is not my opinion but from the makers of LibO.
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Hello
Download the version you want see if it works.
Romke
Download the version you want see if it works.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
Well, yes, I was going to do that...
It was just your comment that LibO says that versions 1 & 2 have bugs, and then they recommend version 2!
It was just your comment that LibO says that versions 1 & 2 have bugs, and then they recommend version 2!
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Hello
I cannot find back the place where I did based my idea but maybe this link tells nearly the same. I'm not sure if I understand it correct.
Romke
I cannot find back the place where I did based my idea but maybe this link tells nearly the same. I'm not sure if I understand it correct.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
Well, it gives the timescale. But in my experience of large software projects, writing code to a timescale is a recipe for disaster. So I'm not sure how the release versions help. How can they know that by week 20 of 2013 (more than a year away!) they will be ready to release a particular stable version?
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Hello
I have no answer for the questions.
Romke
I have no answer for the questions.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: Base: Form events not being called
I don't think I was expecting one!
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
-
- Volunteer
- Posts: 828
- Joined: Fri Nov 30, 2007 10:58 am
- Location: Scotland
Re: Base: Form events not being called
ptoye:
See Drew's post at http://user.services.openoffice.org/en/ ... 457#p32457
I suggest you pick up "Database Programming - OpenOffice.org Base & Basic" by Roberto Benitez, which I bought when it was published in June 2008. I have absolutely no connection with the author but his book has saved me many hours of time. Despite some of its imperfections, I still find it an invaluable source of information.As a retired programmer, I'm used to being able to pick up the book, read it, and start work
See Drew's post at http://user.services.openoffice.org/en/ ... 457#p32457
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
Re: Base: Form events not being called
Thanks. I've had a look at the threads, and they seem a bit divided as to the worth of the book or indeed of Base as a suitable database front-end for all but the most trivial of requirements. And I'm not sure I want to spend any money on a single domestic task (keeping my wines in order).
Most applications come with a suitable manual which comes bundled for free (or, nowadays, as a web site). The problem with OO Basic is that the documentation is so opaque as to obscure any possible value it may have. There's no point in whingeing about the lack of effort available - if the job can't be done properly, don't even bother to start it!
Most applications come with a suitable manual which comes bundled for free (or, nowadays, as a web site). The problem with OO Basic is that the documentation is so opaque as to obscure any possible value it may have. There's no point in whingeing about the lack of effort available - if the job can't be done properly, don't even bother to start it!
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
-
- Volunteer
- Posts: 828
- Joined: Fri Nov 30, 2007 10:58 am
- Location: Scotland
Re: Base: Form events not being called
Chacun.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
Re: Base: Form events not being called
But it hasn't been resolved. Or do you think that OO Basic doesn't need proper documentation?
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
I don't need any macro code to keep inventory lists. My inventories are far from perfect and they require a few clicks/key strokes more than necessary, nevertheless they are fairly well usable by anybody.ptoye wrote:Thanks. I've had a look at the threads, and they seem a bit divided as to the worth of the book or indeed of Base as a suitable database front-end for all but the most trivial of requirements. And I'm not sure I want to spend any money on a single domestic task (keeping my wines in order).
I don't see where API documentation is lacking. Using an object inspector, each object tells everything about itself, the API reference is clearly structured, the overall architecture is well documented. All you need is the bird's eye view of it and an object inspector. I prefer the MRI extension. Yes, there are a few gaps and some things simply do not work as documented but in the end the programming guide is a wiki.
Apart from that, the Basic language makes things unnecessarily complicated.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Base: Form events not being called
Villeroy,
I take your point, and maybe I was being a bit too contentious in my last post (but I like stirring things!). But I still think that the amount of learning needed to write even the simplest macro code is too high for the general user.
I need macro code to keep an audit of when I change things. And (attached to buttons) to perform simple tasks, like indicate that I've drunk a bottle. Yes, I'm lazy that way. But a programmer will spend a month writing code to save a second of time.... And I've always been used to automating tasks where possible. That's what computers are for, after all, not just playing games and writing contentious forum posts.
I'm not familiar with MRI - is this a new invention? I'll look it up. I use XRayTool.
I take your point, and maybe I was being a bit too contentious in my last post (but I like stirring things!). But I still think that the amount of learning needed to write even the simplest macro code is too high for the general user.
I need macro code to keep an audit of when I change things. And (attached to buttons) to perform simple tasks, like indicate that I've drunk a bottle. Yes, I'm lazy that way. But a programmer will spend a month writing code to save a second of time.... And I've always been used to automating tasks where possible. That's what computers are for, after all, not just playing games and writing contentious forum posts.
I'm not familiar with MRI - is this a new invention? I'll look it up. I use XRayTool.
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
-
- Volunteer
- Posts: 828
- Joined: Fri Nov 30, 2007 10:58 am
- Location: Scotland
Re: Base: Form events not being called
ptoye wrote:
I happen to think OOo Basic is fairly well documented. Its API, however, is necessarily complex for the historic need to provide for a variety of operating systems and programming languages. As Villeroy indicates there are ways to adapt to its idiosyncrasies
I apologise for my first post addressing only your specific question. On reading your reply, I indicated how on that point we could each have reasons for arriving at differing conclusions.But it hasn't been resolved. Or do you think that OO Basic doesn't need proper documentation?
I happen to think OOo Basic is fairly well documented. Its API, however, is necessarily complex for the historic need to provide for a variety of operating systems and programming languages. As Villeroy indicates there are ways to adapt to its idiosyncrasies
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
Re: Base: Form events not being called
MRI is very similar but newer than XRay. It has a lot of very convenient extra features to speed up searching. It generates snippets in 4 languages while you use it.
All this can not be discussed without any concrete data. I can track changes without writing macros just keeping lists of items and lists of changes.ptoye wrote: I need macro code to keep an audit of when I change things.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Base: Form events not being called
Well, I think your comment crossed with mine! But I think there has to be something wrong with a language when what appear to be experts in this forum cannot agree on whether variables should be declared as Object or Variant - which I found on one trawl a week or so ago.
We're stuck with it now of course. But personally I find it galling that I can't just start coding without a major learning curve. I managed it with VBA, Java, even Perl (not my favourite language). Not to mention assembler for a number of mainframes and minis back in the 70s and 80s.
We're stuck with it now of course. But personally I find it galling that I can't just start coding without a major learning curve. I managed it with VBA, Java, even Perl (not my favourite language). Not to mention assembler for a number of mainframes and minis back in the 70s and 80s.
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
But are your audit trail lists generated manually or automatically? Triggers don't seem to be supported in OO Base as such (but I expect that I could always insert them using explicit SQL statements).Villeroy wrote: All this can not be discussed without any concrete data. I can track changes without writing macros just keeping lists of items and lists of changes.
Thanks on the data on MRI - I hope I don't have to learn Python as well - so far that's a language I've managed to keep clear of!
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit
Re: Base: Form events not being called
Triggers are supported by your database. Base is NOT a 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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Base: Form events not being called
I'm aware of that! But it IS a database front end. And as such might be expected to support triggers. And, for that matter, update queries. That's up to the designer.
But you can use it to submit arbitrary SQL statements (as I understand it) and so could support triggers.
But you can use it to submit arbitrary SQL statements (as I understand it) and so could support triggers.
Peter
OO 4.1.1 on MS Windows 7 64-bit
OO 4.1.1 on MS Windows 7 64-bit