OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Opening and hiding base documents

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Oldgoat
General User
General User


Joined: 04 Oct 2009
Posts: 9

PostPosted: Sun Oct 04, 2009 4:09 pm    Post subject: Opening and hiding base documents Reply with quote

The 3.x documentation suggests this for opeining a database document but it doesn't seem to work, yielding a message about a "wrapper."

Sub Initialize '=== Triggered by .odb OPEN event
ThisDatabaseDocument.FormDocuments.getByName( "TRANSACTIONS" ).open
End Sub

This, cobbled together from various forum posts, works (opens the desired form) but it doesn't load the form in the same frame, and leaves the .odb document visible to users.

Function OpenFormViaConnection(aFormName as String) as variant

dim sqlconnection as variant
dim oFormContainer as variant
dim oDoc as variant
dim oFrame as variant
dim aProp(1) As New com.sun.star.beans.PropertyValue

'On Error Goto Handle_Error
sqlconnection = thisDatabaseDocument.DataSource.getConnection("","")
aProp(0).Name = "ActiveConnection"
aProp(0).Value = sqlconnection
oFormContainer = thisDatabaseDocument.FormDocuments
If oFormContainer.HasByName(aFormname) Then
oDoc = oFormContainer.loadComponentFromURL(aFormname,"_Self",2,aProp())
oDoc.CurrentController.Frame.ComponentWindow.setFocus()
oFrame = oDoc.CurrentController.Frame
'Toolbars_Hide(oFrame)
End If
OpenFormViaConnection = oDoc

Handle_Error:
If err <> 0 Then
Msgbox "Error " & Err & " occurred loading Form [" & aFormname & "]"
OpenFormViaConnection = NULL
Exit Function
End If
End Function

I'm doing an app that starts with and depends on a switchboard function. Can anyone help with the following?

1. After opening the initial form, I can easily make the top-level .odb document invisible: 'ThisDatabaseDocument.CurrentController.ApplicationMainWindow.SetVisible(False).
But that leaves the .odb running and inaccessible, of course. If a user closes a child form, the whole app closes, but leaves the top document running. You have to execute it again and then close it. How can I hide the top .odb form yet have it go away when the app closes?

2. Notice in the code above the use of "... , _Self, 2, Aprop() " in the LoadComponentFromURL line. This does NOT load the form into the top .odb frame, but creates a new frame. Further, after opening the form, opening another one works, but now there are two frames and two windows for user to manage. That is,

oDoc = oFormContainer.loadComponentFromURL(aFormname,"_Self",2,aProp())
wait(2000)
oDoc = oFormContainer.loadComponentFromURL("ACCOUNTS,)","_Self",2,aProp())

Results in THREE documents open and visible: the top .odb and both forms.

How can I get a form to load in the "current" frame? I've done that extensively with text documents with embedded forms but database documents seem to be a whole different animal.

Thanks for any help
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2696
Location: Apeldoorn, Netherland

PostPosted: Mon Oct 05, 2009 1:01 am    Post subject: Reply with quote

Hello

I cannot give an answer on your question how you ask it.

But maybe this can help you
You can make only a writer document doing the same things as you want.
That means a forms outside a database.

Romke
Back to top
View user's profile Send private message
Oldgoat
General User
General User


Joined: 04 Oct 2009
Posts: 9

PostPosted: Mon Oct 05, 2009 5:20 am    Post subject: Reply with quote

Yes, thanks. I've done that extensively for the past several years, but the 3.x abiilty to handle macros within the database makes Base a better product with a brighter future and I'd like to use the new functionality. Unfortunately I can't make it work.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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