Environment: Windows 10, LibreOffice Version: 18.104.22.168 (x64) Split Database
I have a query called “Menu List” with fields “Menu Item”,“Menu ID”,“FormName”.
I have a form called “Switchboard Main” with a listbox called “Menu”.
The form’s listbox shows a list of menu items - all items show without scrollbar, the idea is that when an item is selected, a form called “FormName” is opened.
For example, a menu item called Sales opens the Sales input form (the formname field for the menu item field).
A few menu items are just an image separator and have as formname “none” hence these menu items are not to be selectable.
The listbox has a macro on item-status-changed
In MsAccess the macro is
Sub Menu_Click() Dim FormToOpen As String FormToOpen = DLookup("[Form Name]", "Menu List", "[Menu Item] = Form.[Menu]") If FormToOpen = "none" Then Exit Sub Else DoCmd.OpenForm FormToOpen End If End Sub
Here my last attempt to find a way in Base but gives a syntax error at SelectedValue and simply does not work at all. (I tried many other ways none worked so no use showing all the failures here)
Sub Menu_Click Dim oForm As Object Dim oField As Object oForm = ThisDatabaseDocument.FormDocuments.getByName("MainForm") oField = oForm.getByName("FormName") const FormToOpen = oField.SelectedValue If FormToOpen = "none" Then Exit Sub Else ThisDatabaseDocument.FormDocuments.getbyname(FormToOpen).open End Sub
I have searched here for solutions and found some with a value list and a separate button that goes to a form based on the position in the valuelist, that basically does the job.
However I want to skip the button, I figure selecting the record in the listbox should be enough to trigger the macro to open the desired form (which works fine in MSAccess with the macro shown).
Also, I can’t use a valuelist and hardcode the macro, since I don’t know in advance the list of menu items because the menu items in the input menu list query is created elsewhere based on user selections of language and functions required.
Have just started moving to LO from MSAccess and overcame many new ways of doing things, I am not getting past this hurdle, could someone pls help me on my way.
For anyone interested here is a demo db working as intended, thanks to the macro help from @Ratslinger.
This shows the usage of a switchboard or menu, to open forms. 2 Styles are included.