How to open a form based on query using button in a mainform and to size and place it on screen

Hi I have libreoffice and using it as frontend for mysql database, using JDBC connector. I have a parameter query based on user input and have created a form based on that query. I am using a form button in a main input form based on a table and I call the query or form by a button which runs a macro to open the form. This macro I got from the web and it is simply:

Sub openFormByTag(oEv)
    cWhat =
    oModel = oEv.Source.getModel()
    sName = oModel.Tag
    oView = oModel.Parent.Parent.Parent.Parent.getCurrentController()
    oView.loadComponent(cWhat, sName, FALSE)
End Sub

What I would like is to run the parameter query/form and size it and have it appear to the right and in front of the mainform. The query/form is really for checking some fields which have to be filled in the main form. Is this possible and can you advise how to code this.
Ideally I would like this query to be to appear as a sub form. Would this be possible?


Edit (moved from not-an-answer answer by @Ratslinger ):

I have a rollcall/attendance table which is filled in with a form. This rollcall table includes fields ‘class id’ and ‘child id’ both linked to two respective tables. I have a parameter query where a teacher can input class ids and it results in details of child name, id and class id, room, teacher id etc, in ascending order based on class id. The main purpose is to give the teacher a check that they are using correct data when filling in the rollcall table.

So far I have a button which runs the query or form based on the query and that seems to run fine but it opens a complete new page and it fills the whole screen. I would like the be able to size the new query or form so that it is readable and on top of or to the right of the main rollcall form.

As I said I run the query with the above macro. I am afraid I can not explain it any better. This may not be the way experts might do this but I am just a novice.


You can place you resulting information in a variety of manners - same form; different form; dialog. It is certainly not clear as to the purpose since it is stated for `’…checking some fields…’ which may mean other methods may be acceptable. Regardless, the lack of direction (different form, sub form) makes it difficult to answer a question such as this. It would require presenting many different scenarios.

Please provide more specifically what you are doing and just what you actually want as an end product. Without these specifics you are asking for someone to present a lot of unrelated code.


You can set the form size and position with a macro. Code is in this post → Open a Base Form in a window

Edit 2020-03-22:

Quick mock-up of form eliminating wasted space:

Even with toolbars present it takes much less space when organized, leaving plenty of room to the side for the other form and even more.

Edit 2020-03-23:

Mock forms side-by-side:

Nearly there. Thanks for link and that seems to work. I wonder if there is a way to keep the form to the front or always on top. If i click on the mainform the resized disappears.


If this was to remain on top or in front it would be a modal dialog - could not do anything until it was closed. Also, then why not just place the data on the existing form? Or open/move this new form off to the side?

Had asked this in my original comment but you seemed to balk at presenting further definition. What you state in this last comment makes no sense.

Hey there’s no hidden agenda on my part and I do not ‘balk’ at anything. From your comment re ‘why not move new form off to the side’ would indicate to me you understand pretty well. As for a modal dialog - I do not know what that is. However, I am willing to learn if people point me in the direction.

In the meantime i have had success , well, it will do me until I find or learn a better method. I have used your resize code - thanks again. That seems to work both in Windows and Linux. As for keeping the form - always on top, I have found a little windows AutoHotkey code called ‘Always on Top’ . And when the form is called and gets focus then by hitting shift+space the form stays on top. I can then return to main form and fill in the fields. The autohotkey application is windows, haven’t managed it in linux yet.

Glad you have something which works for you.

Still have no understanding why this form needs to be on top all the time. As stated put to the side - two forms one next to the other. Again, doesn’t make sense.


Unless, of course, your form takes up the entire screen (if so, never mentioned). Then it is possible the form is too busy and may need to have the functions split into separate forms.

Just all guessing here. Can’t see what you are looking at and what you are thinking. That’s why questions are asked.

And adding another confusing point, you commented:

…or to the right of the main rollcall form.

which adds to the confusion. If it acceptable then what is the problem?

Have seen your screen shots and it appears there is a lot of empty space on each of these screens. Either reduce the size of each screen and place the secondary form along side (has parameters for both size & position) or place the additional data on the same screen in some of that wasted space. You can have many different internal forms on a single form.

This is the avenue I have proposed all along. What is the problem? Also appears you are running these windows maximized. Is there a reason for this?

I don’t know whether these screenshots make it any clearer. I am using propose solution because I don see how I can add images when commenting.
These were grabbed from windows machine which has pretty small screen. Image one is the main rollcall form where user fills in rollcall table. Image 2 is result of button 4, which brings up enlarged new screen, covering whole area. In the parameter box the teacher can choose category they teach. In this instance it is based on afterschool class that is subdivided into several categories. Image 3 is when is resutl of applying resizing macro and calling this great little app autohotkey and the ahk script ‘always on top’. The user can then enter details on the mainform and use the callup query as reference which sits on top.

Please do not use an answer for this. You should edit your question and add there. Did this for you last time you used an answer.