Trying to create a button to open a form

Hi

I am trying to create a button so that it will open up another form. I have tried various macro codes found on here but none of them will work. Any help would be appreciated.

An example of what I have used. The form I am trying to open is called ‘Bonsai Database’.

REM Open a form …
OpenForm(“myForm”)

Regards

Richard

Hello,

It would be nice to show (or at least provide a link to) code you state that you have tried. The example you show is meaningless and doesn’t make any sense on its own.

There is a routine in my answer in this post → Base ERROR - Open Form with macro.

You can then use this sub:

Sub OpenBonsai
    FormChange("Bonsai Database")
End Sub

(terrible form name) attached to the push button Execute action event to open the form.

The routine also has optional code you can remove comments on which will close the existing form.

Edit:

Had already mentioned the code in the link had the info to close a form. Here is a routine for just the closing:

SUB FormClose( sFormName )
  Dim ObjTypeWhat
  Dim ObjName As String
  ObjName = sFormName
  ObjTypeWhat = com.sun.star.sdb.application.DatabaseObject.FORM
  If ThisDatabaseDocument.FormDocuments.hasbyname(ObjName) Then 'Check the form exists'
     ThisDatabaseDocument.FormDocuments.getbyname(ObjName).close  
  Else
      MsgBox "Error! Wrong form name used. "+chr(10)+"Form Name = " & ObjName
  End if
End Sub

and call that routine the same as the open using:

Sub CloseBonsai
    FormCLose("Bonsai Database")
End Sub

Hi there,
I’m trying to build an application menu: a form with buttons to open forms and reports.
To do that I used your macro but it doesn’t work, I always receive an error: “Errore di runtime BASIC.
Variabile dell’oggetto non impostata” means “runtime basic Error. object Variable not set to”
Do I miss something?
Thanks a lot.
Pier Luigi

@plb,

Sorry but never got message for your post (site problems for long time). Only saw now because was searching for information.

Are you still having a problem?

Thanks for your help I appreciate that I wasn’t very helpful in my initial question, as for the code that I had already tried well it was quite a few and cannot remember where they were. The problem is I am very new to databases so I may not know the right questions to ask.
However what you suggested works perfectly thanks, just need to work out a button to close the forms :).

Rich

@woodini254 This is not an answer. Please delete & use add a comment. Answers are to be used to respond to original question only.