Create a macro to open to open a query using push button in base

I have been able to create a macro to open a form using a push button with the following subroutine

Sub OpenLibraryBookMaster
const sNewDocumentName=“LibraryBookMaster”
oNewFormDocument=ThisDatabaseDocument.FormDocuments.getbyname(sNewDocumentName).open
End Sub

I would like to create a macro to open a query I have in the queries section of LO with a push button but have been unable to do so and would be grateful if a subroutine could be shown how I could do this.

Looking forward to answer in anticipation.

HarryMac

1 Like

The relevant tags are base and macro.
I think you should retag the question this way.

Lupp,
Thanks for your suggestion I will retag as suggested.

Having edited the tags, you need to press Enter twice,

Lupp,
Trying to remove tags. How is it done?

I’m not quite sure if tag editing for own questions is supported independent of the “karma”.
If you find the “tool” retag below your question:
a) Click it.
b) Go to the now opened line for editing the tags, and do as needed.
c) Make sure that at least one predefined “major tag” is contained. (In your case base).
d) Quit editing by twice pressing Enter.
Otherwise:
Tell me, and I will do it in your pp.

Lupp,

When I press the retag button I get the row of the tags but cannot find how to delete the unnecessary ones to just leave the relevant base and macro tags?

Well (and sorry!). I needed to do it to be sure how it works.
Basically I could edit the tag line by the same means as any simple text. The process was aggravated a bit by useless flashing lists and the like, but I simply ignored them.
You will need check it with your next question. :wink:

Lupp,
Thanks I now note that just the base and macro tags are there so thanks for doing this for me. I simply could’t do it no matter what I tried.

Thank you, I used the code to open a form with a push button.

Here is a nice piece of code

@gkick,

Thanks - knew I had the code but forgot where. Was just about to search for it.

@gkick

Thanks for the answer and the quick response. The macro and push button are now working perfectly. I am new to LibreOffice and particularly working with macros. This is a terrific forum for tapping into the experts and getting much needed help. Your answer was just what I needed.

@HarryMac,

As you have been helped, please help others to know the question has been answered by clicking on the :heavy_check_mark: in upper left area of answer which satisfied the question.