LibreOffice Basic Open Form with Macro

The macro

Sub Dialog1Show
' References include
' http://stackoverflow.com/questions/27934551/open-a-form-in-libreoffice-openoffice-base-with-a-specific-filter-query
' https://ask.libreoffice.org/en/question/7555/open-form-via-macro-in-libreoffice-base/?answer=45607#post-id-45607
' https://help.libreoffice.org/Basic/Programming_Examples_for_Controls_in_the_Dialog_Editor


    thisDoc = StarDesktop.CurrentComponent
    'MsgBox thisDoc.dbg_properties
    'MsgBox thisDoc.dbg_methods
    thisForm = thisDoc.getdrawpage.getbyindex(2)
    thisID = thisForm.getControl.Text
    'MsgBox "using ID " & thisID

    form_container = ThisDatabaseDocument.FormDocuments.getByName("EditContact")
    form_container.open
    form2 = form_container.component.getDrawPage.getforms.getbyindex(0)
    form2.Filter =("ID = " & thisID)
End Sub

References

http://stackoverflow.com/questions/27934551/open-a-form-in-libreoffice-openoffice-base-with-a-specific-filter-query

https://ask.libreoffice.org/en/question/7555/open-form-via-macro-in-libreoffice-base/?answer=45607#post-id-45607

https://help.libreoffice.org/Basic/Programming_Examples_for_Controls_in_the_Dialog_Editor

The story

In my migration to Linux on the desktop (yes, this is the year for me), I have started converting my Microsoft Access .accdb file to LibreOffice. In my interim I had a really cool jdbc connection, but now was the time to actually get off of that entirely.

Using some instructions for the overly-simple task of exporting and importing data into LibreOffice Base, I got my little table saved to a .ods and then imported into a new, HyperSQL database.

Oh my goodness, HyperSQL is not what I learned in my few database classes during college. I had to rewrite my mid-level-complexity query (the first time for the jdbc connection, and then again) for HyperSQL. Some user-unfriendly documentation exists.

In the function above, the MsgBox contents are debugging info that can provide you with method calls to duckduckgo to get examples and descriptions.

In a future post I might share my “ContactsExtended” query I wrote a long time ago in Access 2010 and have ported up all the way to my current HyperSQL format.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s