Menu Form?

Creating and using forms
Post Reply
qolio
Posts: 2
Joined: Thu Nov 29, 2007 9:07 pm

Menu Form?

Post by qolio »

Hi! I've created a series of forms that I want to be able to open by pressing butons on a master "menu" form. I know how to do this in MSAccess (bad words I know) but I can't seem to do itin Base? Any hints are greatly apprecoiated!
RonIA
Volunteer
Posts: 139
Joined: Mon Oct 08, 2007 1:34 am
Location: Iowa USA

Re: Menu Form?

Post by RonIA »

My understanding is you will need to write a macro to open the form then attach it to the button's On Click Event (Sorry if I am using the wrong event name, not too much experience with OO.oBase.)

MS Access is not a bad word. All applications have a place. There are things MS Office does better than OO.o, there are things OO.o does better than MS Office, there are things Corel Wordperfect does better than both of them, etc...
Ron from Iowa, USA
Jean-Pierre Gastaud
Posts: 4
Joined: Thu Nov 29, 2007 11:48 am

Re: Menu Form?

Post by Jean-Pierre Gastaud »

It has been difficult for me too. But I found on the web a function and a macro to open a form :


Function OpenForm( formContainer as variant, oConnection as variant, sFormName as string, optional strMode as string ) as variant
Dim aProp(1) As New com.sun.star.beans.PropertyValue
dim openMode as string
if ismissing( strMode ) then
openMode = "open"
else
openMode = strMode
endif
aProp(0).Name = "ActiveConnection"
aProp(0).Value = oConnection
aProp(1).Name = "OpenMode"
aProp(1).Value = strMode
OpenForm = formContainer.loadComponentFromURL(sFormName,"_blank",0,aProp())
End Function


Sub onClickOuvrir"FormName"( oEvent as variant )
OpenForm( OEvent.Source.Model.Parent.ActiveConnection.Parent.DatabaseDocument.FormDocuments, OEvent.Source.Model.Parent.ActiveConnection, "Form Name")
End sub
If you want to resize automatically the form this is a macro that can do it :
Sub BaseFormResize
dim oDoc as object
dim oWindow as object

oDoc = thisComponent
oWindow = oDoc.getCurrentController().getFrame().getContainerWindow()
oWindow.setPosSize( 0, 0, 1200, 800, 15 )
End sub
qolio
Posts: 2
Joined: Thu Nov 29, 2007 9:07 pm

Re: Menu Form?

Post by qolio »

Hi Jean-Pierre
Thanks for your help, I'll give it a try, but I was sort of hoping there'd be an easier way than writing code. I'm not all that familiar with that kind of thing (just a newbie).

Wouldn't this be a basic sort of function that anyone wants to do when making a database that has more than one form? As you say RonIA, all software has its strengths and weaknesses, but it seems to me (who knows nothing about such things) that this is a good macro that could be included by the Base developers?

thanks anyway or "tack" as we say in Sweden.
RonIA
Volunteer
Posts: 139
Joined: Mon Oct 08, 2007 1:34 am
Location: Iowa USA

Re: Menu Form?

Post by RonIA »

Also remember, MS Access has been out in the marketplace for over 13(?) years. Though database capabilities have been in OO.o for many many years, OO.o Base has only been a major player for 2-3(?) years. Give it a couple of years. I think with a few modifications and some evolution OO.o Base will be as easy to create db applications (I use this term loosely) as MS Access.
Ron from Iowa, USA
drr999
Posts: 2
Joined: Tue Feb 05, 2008 10:15 pm

Re: Menu Form?

Post by drr999 »

Yes it is a basic function and it worked fine on older versions of OO and StarOffice.

The problem appears (to me) that the forms created under "Create Form in Design View" and "Use Wizard to Create Form"create a form in xml which is hidden somewhere (from us mortal users) but probably accessible under program control. Try this: With Data Sources open and your database and tables open, Go to "Edit Database File"

There is a provision for "Document Information" on the right.
In Open Office (on my machine) this doesn't work(greyed out).
But in Star Office 8, the Document Information for a form always appears as

"Type:
application/vnd.oasis.opendocument.text"

Since Oasis are the underlying xml people, this shows (to me) that the initial forms (created under Create Form in Design View and Use Wizard to Create Form) create a form in xml which is hidden somewhere. Try searching for your newly created form: you won't find it.

When save a form, two choices appear: "Save and "Save as".

If you hit save, you get a save to an unknown location (the hidden xml file) but you won't find it anywhere (as you could in Star Office 7).

But if you hit "Save as ..", you are offered the usual choice of type of text file and location.

So if you save the form to "frogly.odt", you will be able to access the form "frogly.odt" with a menu form with buttons.

When I first did this, the form was not active: no data from the database appeared. On editing the form, I found that saving to text file had "turned off" the connection to the database. To reconnect, edit form, right click on a database field and then "form" to get the dialogue to assign the database and table to the form.

Then it works. Open your menu, click on button to get to form "frogly.odt". It opens. If no data appears, left click in a data field. Data will appear.

If someone knows the "program control way", please help (I'll try the former post on the macro, but I'm not much interested in programming).
drr999
Posts: 2
Joined: Tue Feb 05, 2008 10:15 pm

Re: Menu Form?

Post by drr999 »

Here is an update to my reply above, regarding the location of forms, stating:
"If you hit save, you get a save to an unknown location (the hidden xml file) but you won't find it anywhere"

You will find the form if you unzip the database xyz.odb to get the structure:
xyz.odb
- Configurations2
- META-INF
- database
- forms
(all folders, each form has a subfolder).
If you dig deeper, you get the "content.xml" file for any element.

So the original forms are not hidden, they're just part of the "open" (xml) structure. And that's good -- everything stays together.

But back to the question of "Menu Form?" Above shows that you really do have to save the form to a text file if you want to build a system of linked forms not using programming (the text forms call each other through buttons using:
design mode --> button --> Control --> Properties --> Action: Open document/ webpage
URL: C:\whatnot\whatnext\ form_name.odt)


drr999
florida
Post Reply