Open form function problem

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Open form function problem

Post by Lazy-legs »

Hello,

I'm using the following function to open a specified form in a database (borrowed from http://user.services.openoffice.org/en/ ... =20&t=2326):

Code: Select all

Function OpenForm (FormName As String) as Object
Dim Context As Object
Dim DB As Object
Dim Conn As Object
Dim FormDoc As Object
Dim Form AS Object
Dim Args(1) As New com.sun.star.beans.PropertyValue
Context=CreateUnoService("com.sun.star.sdb.DatabaseContext")
DB=Context.getByName("WriterDB")
Database=DB.getConnection("","")
Args(0).Name="ActiveConnection"
Args(0).Value=Database
Args(1).Name="OpenMode"
Args(1).Value="open"
FormDoc=DB.DatabaseDocument.FormDocuments.loadComponentFromURL (FormName,"_blank",0,Args() )
End Function
But here is the problem that really baffles me. When I add a new record or made changes to an existing one using the opened form, all changes are gone as soon I close OpenOffice.org. I have absolutely no idea why this happens.

Kind regards,
Dmitri
User avatar
DrewJensen
Volunteer
Posts: 1734
Joined: Sat Oct 06, 2007 9:01 pm
Location: Cumberland, MD - USA

Re: Open form function problem

Post by DrewJensen »

Hi Dimitri,

Damn - that is issue 86855 and someone forgot to go back and put up the advanced code needed to open a form for the internal QA staff so they could confirm this.

Anyway - the work around is to open the ODB file first ( hide it if you like ) and then the changes are permanent -

Want an example?
Former member of The Document Foundation
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Re: Open form function problem

Post by Lazy-legs »

Hi Drew,

Ah, I see. This is a rather annoying bug, but I think I can figure out how to open a database before I open a form. If I can't, then I get back and beg for your help. :)

Kind regards,
Dmitri
User avatar
DrewJensen
Volunteer
Posts: 1734
Joined: Sat Oct 06, 2007 9:01 pm
Location: Cumberland, MD - USA

Re: Open form function problem

Post by DrewJensen »

LOL - no I knew you could..
Former member of The Document Foundation
Former member of Apache OpenOffice PMC
LibreOffice on Ubuntu 18.04
Post Reply