| View previous topic :: View next topic |
| Author |
Message |
Danad OOo Advocate

Joined: 22 Feb 2004 Posts: 293 Location: Brasil
|
Posted: Tue Dec 20, 2005 6:04 pm Post subject: How To Load Forms and Reports inside a BASE document |
|
|
Loading Forms and Reports inside a Base document:
| Code: |
Sub openBaseForm
Dim pProp(1) As New com.sun.star.beans.PropertyValue
sURL = ConvertToURL("C:\Documents and Settings\user1\baseDoc.odb")
oDoc = starDesktop.loadComponentFromURL(sURL,"_blank",0,Array())
oForms = oDoc.getFormDocuments()
oAConnection = oDoc.DataSource.getConnection("","")
'set properties
pProp(0).Name = "ActiveConnection"
pProp(0).Value = oAConnection
pProp(1).Name = "OpenMode"
pProp(1).Value = "open" ' OR: openDesign
' load the form: TargetFrameName and SearchFlags aren't used
oFormulario = oForms.loadComponentFromURL("name_of_form","_blank",0,pProp())
End Sub
|
Same way for Reports, but:
| Code: |
oDoc = starDesktop.loadComponentFromURL(sURL,"_blank",0,Array())
oReps = oDoc.getReportDocuments()
' ....
'
oReport = oReps.loadComponentFromURL("name_of_report","_blank",0,pProp())
|
HTH |
|
| Back to top |
|
 |
verycheeky General User


Joined: 27 Mar 2006 Posts: 5
|
Posted: Sun Jun 11, 2006 7:48 pm Post subject: Just open form |
|
|
Hello!
this script works! opens Database and Form! its sooo cool when macros work and no errors!
however.. now i have multiple copies of the same database opened along with forms.
is there anyway to just open the form and not the database associated with it?
Best Regards
M@ |
|
| Back to top |
|
 |
bvdbos OOo Enthusiast

Joined: 23 Nov 2003 Posts: 140 Location: Asten Netherlands
|
Posted: Mon Aug 14, 2006 6:18 am Post subject: parent of oDoc is Base? |
|
|
I'm not in a place to try (will try later) but isn't is something like:
| Code: | oForm=ThisComponent.parent
oForms = oDoc.getFormDocuments()
oAConnection = oDoc.DataSource.getConnection("","")
'set properties |
etc etc? _________________ gr
Bas |
|
| Back to top |
|
 |
Danad OOo Advocate

Joined: 22 Feb 2004 Posts: 293 Location: Brasil
|
Posted: Mon Aug 21, 2006 12:43 pm Post subject: |
|
|
Since I posted that snippet a lot of people asked how to open forms and reports without open the parent base document.
Here is how (quick test with OOo 2.0.3 / XPp):
| Code: |
Sub openOnlyBaseForm
oContexto = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oFonte = oContexto.getRegisteredObject("planilha_2_base")
oForms = oFonte.DatabaseDocument.FormDocuments
oAConnection = oFonte.getConnection("","")
Dim pProp(1) As New com.sun.star.beans.PropertyValue
pProp(0).Name = "ActiveConnection"
pProp(0).Value = oAConnection
pProp(1).Name = "OpenMode"
pProp(1).Value = "open"
oForm = oForms.loadComponentFromURL("form_CALC2BASE", "_blank", 0, pProp())
End Sub
|
Reports ( no test ):
| Code: |
Sub openOnlyBaseReport
oContexto = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oFonte = oContexto.getRegisteredObject("planilha_2_base")
oReports = oFonte.DatabaseDocument.ReportDocuments
oAConnection = oFonte.getConnection("","")
Dim pProp(1) As New com.sun.star.beans.PropertyValue
pProp(0).Name = "ActiveConnection"
pProp(0).Value = oAConnection
pProp(1).Name = "OpenMode"
pProp(1).Value = "open"
oReport = oReports.loadComponentFromURL("rep_CALC2BASE", "_blank", 0, pProp())
End Sub
|
HTH |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1145 Location: France
|
Posted: Tue Aug 22, 2006 12:25 am Post subject: |
|
|
| Danad wrote: | a lot of people asked how to open forms and reports without open the parent base document.
Here is how (quick test with OOo 2.0.3 / XPp) |
Thank you for your snippets, Danad
I have a remark on this one. It is in fact impossible to open a form/report integrated in a Base document without opening it. Your interesting code is a quick method, but it is same as loading the Base document in Hidden mode.
On Windows you can see that a lock file appears when you run the macro. If you close the form by hand, the lock file remains. You have to close the hidden Base document to get the lock deleted. So it is necessary to have a global variable containing access to the Base document, and later close it.
When you close the Base document, opened forms/reports from this document are also closed.
You can get the source with the usual method | Code: | | oFonte = oContexto.getByName("planilha_2_base") |
|
|
| Back to top |
|
 |
Danad OOo Advocate

Joined: 22 Feb 2004 Posts: 293 Location: Brasil
|
Posted: Wed Aug 30, 2006 11:31 am Post subject: |
|
|
| Quote: |
I have a remark on this one. It is in fact impossible to open a form/report integrated in a Base document without opening it.
|
As usual, you're right.
| Quote: |
Your interesting code is a quick method, but it is same as loading the Base document in Hidden mode.
|
I'm not sure about this. After loading a document in Hidden mode, it can be enumerated as a component.
| Quote: |
On Windows you can see that a lock file appears when you run the macro. If you close the form by hand, the lock file remains.
|
Yes, I saw that. But here after some runs, suddenly, this behaviour was gone and I don't know why.
| Quote: |
You can get the source with the usual method:
|
But why not give a try to the others ?
Bernard, yours comments are full of enlightenment.
Thanks. |
|
| Back to top |
|
 |
Roofoos General User

Joined: 06 Jan 2007 Posts: 16 Location: Bolzano- Italy
|
Posted: Wed Jan 10, 2007 7:53 am Post subject: |
|
|
Is it possibile to open "current record position" from a form to another form??
for example, i have a list box, I choose "Roberto", then i click the button "view details" and another form will open directly to "Roberto" record position.
thank you.. |
|
| Back to top |
|
 |
trenkler Power User

Joined: 21 May 2005 Posts: 55
|
Posted: Sun Jan 28, 2007 2:44 pm Post subject: |
|
|
| Roofoos wrote: | Is it possibile to open "current record position" from a form to another form??
for example, i have a list box, I choose "Roberto", then i click the button "view details" and another form will open directly to "Roberto" record position.
thank you.. |
Yes. You have to open form with something like oForm.filter= variable which shows the record position of Roberto.
juraj |
|
| Back to top |
|
 |
cordelia Newbie

Joined: 11 Oct 2007 Posts: 1
|
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2599 Location: Cumberland, MD
|
Posted: Sat Oct 27, 2007 7:33 pm Post subject: |
|
|
| B Marcelly wrote: | | Danad wrote: | a lot of people asked how to open forms and reports without open the parent base document.
Here is how (quick test with OOo 2.0.3 / XPp) |
Thank you for your snippets, Danad
I have a remark on this one. It is in fact impossible to open a form/report integrated in a Base document without opening it. Your interesting code is a quick method, but it is same as loading the Base document in Hidden mode.
On Windows you can see that a lock file appears when you run the macro. If you close the form by hand, the lock file remains. You have to close the hidden Base document to get the lock deleted. So it is necessary to have a global variable containing access to the Base document, and later close it.
When you close the Base document, opened forms/reports from this document are also closed.
You can get the source with the usual method | Code: | | oFonte = oContexto.getByName("planilha_2_base") |
|
Hi,
the lock file you are talking about is the file created by the HSQLdb engine. In the case of an embedded database file, then yes the ODB file is opened by the connection manager. The *.lck remaining after the form is closed is only the case if there is any other OpenOffice.org window (object ) open ( this includes the Quckstarter )
This is a known problem where the JRE does not automatically release the connection just because the form has been closed.
One way around this is to explicitly dispose of the variable holding the connection. Kind of the same thing as the global variable for the hidden document. The developers swear that this should not be necessary, but it sure is every time I test it.
One other the thing to remember is that not all ODB files include the embedded database. So if we are connecting to PostgreSQl, for instance, then all the ODB file holds is the definition of the connection, not the data. In this case the form is extracted and the connection created. The ODB file itself should not be opened at this point.
To be honest I am not even sure the ODB file is open, by one definition anyway, even in the embedded model above. If you say you have tested this I'll believe you. But the *.lck file not being deleted when the form is closed does not equate the odb file being open at all.
EDIT - well, gee...I suppose I might be all wet three...LOL...now I am going to have to off and try to test this also...I'll let ya'll know how that goes... _________________ Blog - http://baseanswers.spaces.live.com/ |
|
| Back to top |
|
 |
|