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

(Solved) Open base with Start-up form

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
bluec22
General User
General User


Joined: 26 Apr 2007
Posts: 46
Location: Netherlands

PostPosted: Fri Mar 21, 2008 3:14 am    Post subject: (Solved) Open base with Start-up form Reply with quote

Hi all,
I just wonder is it possible to have a form to open automatically when you start your database?
Cheers


Last edited by bluec22 on Tue Mar 25, 2008 5:57 am; edited 1 time in total
Back to top
View user's profile Send private message
QuazzieEvil
Super User
Super User


Joined: 17 Jan 2007
Posts: 599
Location: Houston, TX

PostPosted: Fri Mar 21, 2008 6:25 pm    Post subject: Reply with quote

you can try the following code
Code:

Sub AutoExec
On Error Goto HandleError
   Dim LastFrame As Object
   Dim NumFrames As Integer
   Static FormDocs As Object
   Dim DBDoc As Object
   Dim ImpName As String
   Dim DataSource As Object
   Dim Conn As Object
   Dim Args(1) As New com.sun.star.beans.PropertyValue
   Dim FormName As String
   Dim FormDoc As Object

   FormName="Form1"  REM CHANGE TO YOUR FORM NAME
   ImpName="com.sun.star.comp.dba.ODatabaseDocument" REM implementation name for a db doc
   NumFrames=StarDesktop.Frames.Count
   LastFrame=StarDesktop.Frames.getByIndex(NumFrames-1) REM 0 BASED
 REM A BASE FORM OPENS AS A CHILD FRAME INSIDE THE BASE FRAME
 REM SO, THE TOP FRAME IN THE DESKTOP IS STILL BASE WHICH CAUSES THIS CODE TO FINISH
 REM EXECUTION EVERY TIME A FORM IS OPENED
 REM SO, I CHILL CHECK TO SEE IF THE LAST FRAME HAS SUB FRAMES, IF SO, EXIT
 REM NOT AN IDEAL SOLUTION, BUT IT WILL DO FOR NOW
 
 If LastFrame.Frames.Count>1 Then
     Exit Sub
    End If
   If Not (LastFrame.Controller.Model.ImplementationName=ImpName) Then
      Exit Sub REM not a db doc
   End If
   DataSource=LastFrame.Controller.DataSource
   DBDoc=DataSource.DatabaseDocument
   FormDocs=DBDoc.FormDocuments
   Conn=DataSource.getConnection("","") REM  no user/password
   Args(0).Name="ActiveConnection" : Args(0).Value=Conn
   if FormDocs.hasByName(FormName) Then
      FormDoc=FormDocs.loadComponentFromURL(FormName,"_self",2,Args() )
      FormDoc.CurrentController.Frame.ContainerWindow.setFocus()
   End If
HandleError:
   If Err<>0 Then
      Exit Sub
   End If
End Sub

save it somewhere in your macros library-->tools | macros | organize macros | Openoffice.org Basic
---> save in any of your libraries (my macros) or create a new one.

now, open Base and goto Tools | customise and open the events tab, and select the 'Open Document' event. now click on the macro button (top right) and browse for the macro you just saved. you can not save an event specifically for Base, so this macro will execute for every base document, but will exit if the doc is not a Base doc.

ALSO, i wrote this code with the intention to use it to load a switchboard. if you close the startup form, and manually open another form, this code will execute again--and open the start up (switchboard) form again.

--hope it helps.
Back to top
View user's profile Send private message Visit poster's website
bluec22
General User
General User


Joined: 26 Apr 2007
Posts: 46
Location: Netherlands

PostPosted: Tue Mar 25, 2008 5:59 am    Post subject: Reply with quote

Thanx QuazzieEvil,
It works for me so far. Only one small problem, it opens the form whenever I open any base file, and even Impress as well.
Cheers,
Back to top
View user's profile Send private message
hzman
General User
General User


Joined: 13 Dec 2008
Posts: 6

PostPosted: Sat Dec 13, 2008 8:20 am    Post subject: Minimizing the pogram window Reply with quote

Hi folks! I was looking for the solution to this same problem, and found the answer here, Thank You! I'm using the SWITCHBOARD in my database, and the form loads up nicely. I would like to hide/ minimize the Main Program window from the behind, so...

Is there a function or script or line of code to do so? It would be nice bonus.

Even better would be to minimize the program window to the system tray. Like this small program..

"TrayIt! allows to save precious Taskbar space for minimized windows. For each application which applies TrayIt! it creates a small icon in the System Tray. (System Tray area is located near the Clock). When application's window is minimized this icon represents the application on the Taskbar instead of the regular "minimized rectangle"."

It would be nice to have the SWITCHBOARD to be run like "standalone".

Thank you for your help, Hermanni, Finland.
Back to top
View user's profile Send private message
jmckay
General User
General User


Joined: 04 Jun 2009
Posts: 26

PostPosted: Sun Jun 21, 2009 8:14 am    Post subject: Reply with quote

HI

This is great... but I have a few issues.

I am using a MySql DB connected to OO base.

If I have logged onto the DB and then close and open the odb file the form will load automatically, however if I haven't yet logged on it just loads the DB then I have to click on something before being prompted to login, after which the form does not load automatically.

Is their any way I can make it so when the ODB file it launched it automatically asks the user to login then launches the main form?

Any help would be great!

Thanks,
James
Back to top
View user's profile Send private message
emari2
Newbie
Newbie


Joined: 18 Nov 2009
Posts: 3

PostPosted: Thu Nov 19, 2009 11:35 am    Post subject: THANKS. DO YOU HAVE A SOLUTION FOR THIS? Reply with quote

Sub appProb()

On Error GoTo 1

Dim XLTable As TableDef

Set Db = OpenDatabase(mdbFile)
Set XLTable = Db.CreateTableDef("tblProbTemp")

XLTable.Connect = "Excel 5.0;DATABASE=" & xlsFile
XLTable.SourceTableName = "tblXLProb"
Db.TableDefs.Append XLTable

strSQL = "Insert into tblProb Select * FROM tblProbTemp"
Db.Execute strSQL

1:
Err.Clear
On Error Resume Next
Db.TableDefs.Delete "tblProbTemp"
Db.Close

kind regards
Back to top
View user's profile Send private message
djskafish
General User
General User


Joined: 24 Nov 2009
Posts: 38

PostPosted: Tue Dec 01, 2009 12:52 pm    Post subject: Reply with quote

Would it be possible to have a code that allows you to close the switchboard and NOT reload it every time you open a form?
Back to top
View user's profile Send private message
Glen Darby
General User
General User


Joined: 30 Aug 2007
Posts: 13

PostPosted: Tue Feb 02, 2010 10:26 am    Post subject: Problem using this script Reply with quote

Hi,
I have found a problem using the AutoExec script, which confuses me somewhat....

The script runs fine on opening the Switchboard, the Switchboard runs fine and does it's job opening the relevant forms needed......

However on entering data and closing the forms, the data is never saved???

I Turn off the AutoExec Script and open the Switchboard manually and everything seems fine, everything saves ok etc????

Can anyone shed any light on this problem please.... I would love to have and AutoExec working.

Thanks in advance.

Glen.
Back to top
View user's profile Send private message
RPG
Super User
Super User


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

PostPosted: Tue Feb 02, 2010 10:41 am    Post subject: Reply with quote

Hello

Are you working with a form inside a database document?

Maybe there are two solutions.
a) work with a stand alone form
b) flush your data before closing the connection.

see this link at the end
Romke
Back to top
View user's profile Send private message
emeant
Newbie
Newbie


Joined: 01 Feb 2011
Posts: 1

PostPosted: Tue Feb 01, 2011 10:42 am    Post subject: Reply with quote

jmckay.I would like to make it launched it automatically asks the user to login then launches the main form.Anyone? Sad
Back to top
View user's profile Send private message
RPG
Super User
Super User


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

PostPosted: Tue Feb 01, 2011 2:44 pm    Post subject: Reply with quote

Hello

This ia a tutorial about dataloss. It is important when you dataloss without a crash When your database has crashed then look here.

The reason of this dataloss is: The data is not written to the tables. I will and can not complete the describe the reason of the data loss. I have read several reason of this data loss
a) Database is opened when you click on the database in a file manager. Then you use macros for opening forms.
b) You open embedded forms with macros from outside this database.

In all cases you can get several problems with your database.
a) No connection
b) Dataloss


This macro you can use for checking if there is a connection.
Code:
with Thisdatabasedocument.currentcontroller
   if  not .isConnected then  .connect
end with



Code:
Thisdatabasedocument.currentcontroller.datasource.flush


The first macro must be runed when you need checking the connection of the database. use the event: OpenDocument.
The second macro you have to use when you did have closed the database and notice data loss. Use the event: View Closed.


The events are part of the database document. There where you can see the forms names and table names.

menu --> tools --> customize.

the fourth from above : Open Document.
the nineth ( 9) from above : View closed.


Romke
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 Base 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