0

I don't want users can see the tables, bar menu, etc of main Base app, I need users only can see the forms and subforms to enter data or show reports from search queries at the database. Thanks!

  • Welcome! Look at these [**four lines**](https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=34214&p=156973#p156975) – JohnSUN Feb 17 '22 at 06:15

1 Answers1

0

Changing the visibility of any window is simple:

Sub setVisibleMainWindow(bVisible As Boolean)
    ThisDataBaseDocument.getCurrentController().getFrame().getContainerWindow().setVisible(bVisible)
End Sub

Only call this procedure when opening the form. For example, like this:

Sub openDefaultForm( )
Const MAIN_FORM_NAME = "DataForm"
    If ThisDatabaseDocument.FormDocuments.hasbyname(MAIN_FORM_NAME) Then 
        ThisDataBaseDocument.CurrentController.Connect() 
        ThisDatabaseDocument.CurrentController.loadComponent(com.sun.star.sdb.application.DatabaseObject.FORM, MAIN_FORM_NAME, FALSE) 
        setVisibleMainWindow(False)
    Else
        MsgBox "Something happened to the " & MAIN_FORM_NAME & " form!"+ chr(10)+"You deleted? Or renamed?" , 48, "Form not found"
    End if
End Sub

And don't forget to make this window visible before shutting down:

Sub beforeClose(oEvent As Variant)
    setVisibleMainWindow(True)
End Sub

Now use Tools - Customize - Events tab to assign the openDefaultForm() procedure as the database's "Open Document" event handler, and the beforeClose() procedure as the "Document is going to be closed" event handler for the form.

JohnSUN
  • 2,268
  • 2
  • 5
  • 12