| View previous topic :: View next topic |
| Author |
Message |
Matt Krzywonski General User

Joined: 20 Jul 2007 Posts: 19 Location: South Padre Island, Texas
|
Posted: Wed Aug 08, 2007 8:53 am Post subject: Close form macro... |
|
|
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.  _________________ 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 |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Wed Aug 08, 2007 10:01 am Post subject: |
|
|
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 |
|
 |
Matt Krzywonski General User

Joined: 20 Jul 2007 Posts: 19 Location: South Padre Island, Texas
|
Posted: Wed Aug 08, 2007 10:45 am Post subject: Many many many thanks... |
|
|
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 |
|
 |
papo General User

Joined: 09 Sep 2007 Posts: 8 Location: Poland, Szczecin
|
Posted: Sun Sep 09, 2007 1:46 am Post subject: problem with close button |
|
|
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 |
|
 |
Evgenych General User

Joined: 03 Jan 2008 Posts: 9
|
Posted: Wed Jan 30, 2008 6:37 am Post subject: |
|
|
| 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 |
|
 |
kraf101 Power User

Joined: 02 Mar 2005 Posts: 56
|
|
| Back to top |
|
 |
Robby OOo Advocate

Joined: 21 Sep 2004 Posts: 249
|
Posted: Fri Jun 06, 2008 11:03 pm Post subject: |
|
|
xxx
Last edited by Robby on Sun Dec 11, 2011 1:36 am; edited 1 time in total |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sat Jun 07, 2008 1:57 pm Post subject: |
|
|
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 |
|
 |
Robby OOo Advocate

Joined: 21 Sep 2004 Posts: 249
|
Posted: Sat Jun 07, 2008 9:28 pm Post subject: |
|
|
xxx
Last edited by Robby on Sun Dec 11, 2011 1:36 am; edited 1 time in total |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jun 08, 2008 12:40 am Post subject: |
|
|
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 |
|
 |
Robby OOo Advocate

Joined: 21 Sep 2004 Posts: 249
|
Posted: Sun Jun 08, 2008 2:35 am Post subject: |
|
|
xxx
Last edited by Robby on Sun Dec 11, 2011 1:37 am; edited 1 time in total |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jun 08, 2008 3:06 am Post subject: |
|
|
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 |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jun 08, 2008 3:50 am Post subject: |
|
|
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 |
|
 |
Robby OOo Advocate

Joined: 21 Sep 2004 Posts: 249
|
Posted: Sun Jun 08, 2008 11:42 am Post subject: |
|
|
xxx
Last edited by Robby on Sun Dec 11, 2011 1:37 am; edited 1 time in total |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jun 08, 2008 3:28 pm Post subject: |
|
|
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 |
|
 |
|