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

Close form macro...
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
Matt Krzywonski
General User
General User


Joined: 20 Jul 2007
Posts: 19
Location: South Padre Island, Texas

PostPosted: Wed Aug 08, 2007 8:53 am    Post subject: Close form macro... Reply with quote

Hello all, I have been searching the forums for a solution to this problem. I am still very much a newb but my understanding has increased greatly over the last couple months. My problem is that I have a Base form with a button macro assigned to the mouse button pressed action. It is as follows;

Code:
Sub OpenFormAppointmentsAll(Event As Object)
   Dim Form As Object
   Dim FormDoc AS Object
   Dim FormCollection As Object
   Dim DBDoc As Object
   Dim Args(1) As New com.sun.star.beans.PropertyValue
   
   Form=Event.Source.Model.Parent
   FormCollection=Form.Parent
   FormDoc=FormCollection.Parent   
   DBDoc=FormDoc.Parent

   Args(0).Name="ActiveConnection"
   Args(0).Value=Form.ActiveConnection
   Args(1).Name="OpenMode"
   Args(1).Value="open"

   DBDoc.FormDocuments.loadComponentFromURL("AppointmentsAll","_blank",0,Args())
End Sub


This works fine. What I want to do is concurrently close the current document, lets say it's called "CalenderNav", by assigning a macro to the mouse button released action. I tried the following;

Code:
Sub CloseFormCalenderNav(Event As Object)
   Dim Form As Object
   Dim FormDoc AS Object
   Dim FormCollection As Object
   Dim DBDoc As Object
   Dim Args(1) As New com.sun.star.beans.PropertyValue
   
   Form=Event.Source.Model.Parent
   FormCollection=Form.Parent
   FormDoc=FormCollection.Parent   
   DBDoc=FormDoc.Parent

   Args(0).Name="ActiveConnection"
   Args(0).Value=Form.ActiveConnection
   Args(1).Name="CloseMode"
   Args(1).Value="close"

   DBDoc.FormDocuments.loadComponentFromURL("CalenderNav","_blank",0,Args())
End Sub


This did not work at all and I don't have a clue where I am going wrong. Does the OpenForm macro need to be modified to include a CloseForm routine? I have the relatively simple goal of using buttons to navigate through my developed database and have the previous form close when applicable.

Thanks for the help, you have all been an invaluable asset to me in the last months. Very Happy
_________________
Matt Krzywonski | Sales Representative
Texas | Northern Mexico

Phone: 956.943.4418 | Fax: 956.943.4418

Aquarius Laser Etching and Design
1240 Alice Street, Suite A
Woodland, CA 95776

Phone: 530.666.3989 | Fax: 530.666.2702
Back to top
View user's profile Send private message Visit poster's website
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Wed Aug 08, 2007 10:01 am    Post subject: Reply with quote

It would be nice if you could just do something like

oFormVariable.close( true )

but that just doesn't want to work.

What does work is if you close the frame that the form is in.taking your example I could change it to:

Code:

Sub OpenFormAppointmentsAll(Event As Object)
   Dim Form As Object
   Dim FormDoc AS Object
   Dim FormCollection As Object
   Dim DBDoc As Object
   Dim Args(1) As New com.sun.star.beans.PropertyValue
   
   Form=Event.Source.Model.Parent
   FormCollection=Form.Parent
   FormDoc=FormCollection.Parent   
   DBDoc=FormDoc.Parent

   Args(0).Name="ActiveConnection"
   Args(0).Value=Form.ActiveConnection
   Args(1).Name="OpenMode"
   Args(1).Value="open"

  REM - to close the current form
  REM - just before the new one opens
  REM - get a reference to the current form
  REM - and then the controller for the form
  REM - and finally from that FRAME it is in
  REM - then close that
  thisComponent.CurrentController.Frame.close( true )
          DBDoc.FormDocuments.loadComponentFromURL("AppointmentsAll","_blank",0,Args())
End Sub

_________________
Blog - http://baseanswers.spaces.live.com/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Matt Krzywonski
General User
General User


Joined: 20 Jul 2007
Posts: 19
Location: South Padre Island, Texas

PostPosted: Wed Aug 08, 2007 10:45 am    Post subject: Many many many thanks... Reply with quote

Drew, you have been an absolute lifesaver to me over the last couple months. This was basically the last step in making my database completely user friendly. This should hold the company until I can hire a full time IT person. Again, many thanks and my sincerest gratitude for all the help you and others provide in this forum, it is truly wonderful.

Sincerely,
_________________
Matt Krzywonski | Sales Representative
Texas | Northern Mexico

Phone: 956.943.4418 | Fax: 956.943.4418

Aquarius Laser Etching and Design
1240 Alice Street, Suite A
Woodland, CA 95776

Phone: 530.666.3989 | Fax: 530.666.2702
Back to top
View user's profile Send private message Visit poster's website
papo
General User
General User


Joined: 09 Sep 2007
Posts: 8
Location: Poland, Szczecin

PostPosted: Sun Sep 09, 2007 1:46 am    Post subject: problem with close button Reply with quote

Hello.
My name is Przemek and I am from Poland. This is my first post on this forum.
Please forgive me my english.

I can not creat close button on form. I can see how to creat open butto, and "CalenderNav" on Your post, but I need simply close button on my form.
Back to top
View user's profile Send private message
Evgenych
General User
General User


Joined: 03 Jan 2008
Posts: 9

PostPosted: Wed Jan 30, 2008 6:37 am    Post subject: Reply with quote

Code:

function curFormName (o as object) as string
   args = o.getArgs
   for i = lBound(args) to uBound(args)
      if args(i).name = "DocumentTitle" then
         curFormName = args(i).value
         exit for
      end if
   next
end function

sub onCloseButton( oEvent as object )
            msgbox curFormName(thisComponent)
   thisComponent.parent.FormDocuments.getByName(curFormName (thisComponent)).dispose()
end sub

p.s.
If close current frame, next time you open the form On load form event doen't run.
Back to top
View user's profile Send private message
kraf101
Power User
Power User


Joined: 02 Mar 2005
Posts: 56

PostPosted: Thu Jan 31, 2008 9:45 am    Post subject: Re: problem with close button Reply with quote

papo wrote:
Hello.
My name is Przemek and I am from Poland. .

Hi Przemek,

check :http://www.oooforum.org/forum/viewtopic.phtml?t=53119&highlight=

If you need more help, ask me in polish with Private Message.

RAF
Back to top
View user's profile Send private message
Robby
OOo Advocate
OOo Advocate


Joined: 21 Sep 2004
Posts: 249

PostPosted: Fri Jun 06, 2008 11:03 pm    Post subject: Reply with quote

xxx

Last edited by Robby on Sun Dec 11, 2011 1:36 am; edited 1 time in total
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: Sat Jun 07, 2008 1:57 pm    Post subject: Reply with quote

Hello Robby

You must not close thiscomponent but you must use there the name of the component you want close.
I am not sure. I have not work with it. But I have do a test and it is working. May be you try something else I don't understand.

Thiscomponent stand for that document where the macros are, and not an other.Thiscomponent means real thiscomponent

I cannot give a name

Romke
Back to top
View user's profile Send private message
Robby
OOo Advocate
OOo Advocate


Joined: 21 Sep 2004
Posts: 249

PostPosted: Sat Jun 07, 2008 9:28 pm    Post subject: Reply with quote

xxx

Last edited by Robby on Sun Dec 11, 2011 1:36 am; edited 1 time in total
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: Sun Jun 08, 2008 12:40 am    Post subject: Reply with quote

Hello Robby
do thing like this

Code:
 dim newform
newform = OpenForm( formContainer , oConnection , sFormName )' Fill in your own value
' Do the action you want
print newform.implementationname ' Must be of a document valuw like swxtextdocument
newform.CurrentController.Frame.close( true )


A function gives always back a value. In the function you always a line where the function gets his value

I have not test this
I hope it is more clear

Romke
Back to top
View user's profile Send private message
Robby
OOo Advocate
OOo Advocate


Joined: 21 Sep 2004
Posts: 249

PostPosted: Sun Jun 08, 2008 2:35 am    Post subject: Reply with quote

xxx

Last edited by Robby on Sun Dec 11, 2011 1:37 am; edited 1 time in total
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: Sun Jun 08, 2008 3:06 am    Post subject: Reply with quote

Hello Robby

You have right. I did think you need only a statement for closing a file and i did not fully understand your problem. I cannot give an answer on this moment why I don't know it. But I will study on it there it is interesting. Sorry
Working with two writer-documents was always difficult for me. I have make more frame in one document. But I do also learn much with all answer. So I will try it again. If I knew thing i write it

Romke
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: Sun Jun 08, 2008 3:50 am    Post subject: Reply with quote

Hello Robby

I do the following
I have open a write_document name test
With a button I open a other write_document name formulier
next I close the test document with the same instruction as you do
thiscomponent.CurrentController.Frame.close( true )

It happens without errors and the new document formulier is displayed


This is not the same as I told earlier sorry. I now better understand what you want and what happens all.
Can be the problem that you use OOo 2.4 and I use OOo2.3..0.1.5..
Now I have it real test, and that is better
Romke
Back to top
View user's profile Send private message
Robby
OOo Advocate
OOo Advocate


Joined: 21 Sep 2004
Posts: 249

PostPosted: Sun Jun 08, 2008 11:42 am    Post subject: Reply with quote

xxx

Last edited by Robby on Sun Dec 11, 2011 1:37 am; edited 1 time in total
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: Sun Jun 08, 2008 3:28 pm    Post subject: Reply with quote

Hello Robby
This two line of code does all thing as you want.
The first line opens a new document of the name "formulier1"
the second line close the old document
the third line works the same. The name is not important for closing.

If you really want have the names the problem is else.

And I think that there is a problem with OOo2.4. Wait for a couple of weeks and we get a new version of OOo and I think and hope the problem are over.I don't get errors

I hope this helps you

Romke


Code:
WriterForm=OpenForm(getFormsTC, getConnectionTC,"Formulier1")'De open form komt met een tekstfile terug en open een  nieuw  formulier
StarDesktop.CurrentComponent.CurrentController.Frame.close( true )
'thiscomponent.CurrentController.Frame.close( true )
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
Goto page 1, 2  Next
Page 1 of 2

 
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