| View previous topic :: View next topic |
| Author |
Message |
thierry Newbie

Joined: 19 Jul 2005 Posts: 2
|
Posted: Tue Jul 19, 2005 6:38 am Post subject: Buttons, still looking... |
|
|
Well, have done a bit of Access but am newer to Oo Base... Question has popped-up a few times in the forum but answers not really usable it seems:
How do you tell a button on a form to open another form?
URL's don't seem to work with these objects (limited to files and www?) Drag and drop of form to URL container does not work for me either...
Thanks! _________________ TCo |
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Tue Jul 19, 2005 5:01 pm Post subject: Buttons - Events and URLS |
|
|
Thierry
It seems to me as I read the forum that there is a bit of confusion about the two subjects you rase.
The first is the use of URL in places that new users expect to see FILENAME. Further in the case of the new OOO Base a URL in place of FORM NAME.
Specifically the use of a URL in the LoadComponentFromURL command.
As you seem to imply you 'get' the idea of converting an Operating System specific file name to URL , but the addition of database files that contain forms and reports seems not to mesh with the concept.
It's simple, in the case of form and report documents embedded in an OOo Base database file the URL is the name of the document.
So if I had a stand alone form document named Form1.odt, c:\dbForm\Form1.odt the URL would be:
"file:///C:/dbForms/Form1.odt"
If the same form where embedded in a database file its URL would be
"Form1"
The next thing about loading this embedded form that is different is WHICH component can actually perform the command LoadComponentFromURL for us.
In the case of our embedded form this could be handled ONLY by the DocumentContainer of the database file that holds the form.
So, if you tried to do something like this:
| Code: |
oFrame = ThisComponent.getCurrentController().getFrame()
oDoc = oFrame.LoadComponentFromUrl("Form1", "", 2, mArgs())
|
You would generate an error, because the frame has no idea what the URL "Form1" refers to.
But if you did this
| Code: |
oDBFrame = StarDeskTop.loadcomponentfromURL(ConvertToURL(oDialog.getControl( "fldDataBaseFile" ).Text),"_Hidden", 63, Array())
oFormDoc = oDBFrame.getFormDocuments.LoadComponentFromURL("Form1" ,"_Blank" , SearchFlags ,Args() )
|
Then you have an open form, because the FormContainer knows the URL ( "Form1" ) as one of the forms it contains.
The reason the URL is different is because in the first case, a frame object, you must tell it : What you want to load, where it is located and its name. While in the case of the embedded formcontainer it alread knows what you want, a form, and where it is located so all you need supply is the name.
Now for your queston Telling a Button .. .that is in the next message.. |
|
| Back to top |
|
 |
thierry Newbie

Joined: 19 Jul 2005 Posts: 2
|
Posted: Wed Jul 20, 2005 7:49 am Post subject: |
|
|
Drew,
Thanks, this helps... but I did mention I was new to Oo! I went out and took a look at A. Pitonyak's doc on macros. Will need some time to digest! I tried copying the code you provided (I understand some of it but not all). Tried adding som DIM statements but something is still missing to get it working.
I am trying to run the macro in a Database called "Accounting' and I would like a button named "Go to members" residing on a form called "Welcome" to open another existing form in the same database that is named "Members".
Would I be abusing by asking you what the misdsing code is to get this working ?! I am sure a lot of others would be delighted to see a complete example!!
Many thanks
Thierry _________________ TCo |
|
| Back to top |
|
 |
millek Newbie

Joined: 23 Aug 2005 Posts: 1
|
Posted: Tue Aug 23, 2005 5:16 am Post subject: button to open a new form |
|
|
Hi,
I have the same problem.
I understand from this topic that I have to insert change some code in the macros... but how to find the place where I should put this code? I open the Macro Organizer from the main OO window and get stuck.
Do I change (or create) new macro only for this button, or do I open a general macro which serves all buttons in a particular database, or do I influence the OpenOffice "build-in" macro which influences all databases I have on my computer?
Emilia |
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Tue Aug 23, 2005 10:35 am Post subject: Brief example |
|
|
Ok, I am not sure if this will help or not.
I will post something a bit more detailed about my way of working with forms, and events on the Code Snippet list in a day or two. But until then, here is a working example from a little utitlity I built for myself that I use a lot.
Here is a screen shot of a dialog box.
See the 'Open Forms buttont. It is attached in the 'On Initialize' event to this macro:
| Code: |
sub OpenForm
dim enForms as object
dim oFormDoc as Object
dim oFrame as Object
dim Args(1) as new com.sun.star.beans.PropertyValue
oframe = StarDeskTop.CurrentComponent
' open a OooBASE frame
oDBFrame = StarDeskTop.loadcomponentfromURL( _
ConvertToURL( _
oDialog.getControl( "fldDataBaseFile" ).Text), _
"_Hidden", 63, Array())
' get the document container
enForms = oDBFrame.DataSource.DataBaseDocument.getFormDocuments
' get the document definition
oForm = enForms.getbyName( oDialog.getcontrol( "lbxForms").selectedItem )
' get the connection
oDBConnection = oDBFrame.DataSource.getConnection("","")
' set up the property values for the command
Args(1).name = "OpenMode"
Args(1).value = "open"
Args(0).name = "ActiveConnection"
Args(0).value = oDBConnection
oFormDoc = oDBFrame.getFormDocuments.LoadComponentFromURL(oform.name ,"_Blank" , 0 ,Args() )
end sub
|
Just one thing to point out. The variable "oFormDoc" is declared as a GLOBAL earlier in the dbBrowser library. You need to do this so that the newly opened forms do not get cloberd if you reopen the dbBrowser dialogbox.
When I post to Code Snippets I will include a link to the utility that this code is part of.
HTH
Drew Jensen _________________ Blog - http://baseanswers.spaces.live.com/ |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|