| View previous topic :: View next topic |
| Author |
Message |
giga Newbie

Joined: 20 Jan 2009 Posts: 3
|
Posted: Tue Jan 20, 2009 9:22 pm Post subject: Adding a Button To Open Another Form |
|
|
Good day
I am currently building a data base that will be distributed on an Auto run CD with open office installer on the CD and I need some help
I need a button to open another form in the database using OpenOffice 3.1
Can you give detailed instructions on how to do this and the code to change if another button is added with the same function to open a different form.
The buttons must work on all computers that the data base is activated on?
I have already built the CD with the auto-run html interface and an access data base all i need now is a opensouce version of the database .
Thank you for your help
giga
this image shows how the forms will interact
http://www.graftonit.info/adam/images/help.bmp |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Wed Jan 21, 2009 4:27 am Post subject: |
|
|
Hello
this code opens a form
If you access the data base with macro's maybe you get problems.
I suppose you want only open a form and that is what the macro is doing
I don't know if it will working in the way you write. This works on a standard registered database in OOo3.0 You write about a CD and I don't know if it works in that way
Romke
| Code: | sub openform_again
dim oCurrentController
'Variables for document what will be opened
dim sNewfileFormName ' This is the name how it is in the database
dim oNewformtoSee ' Object for the new form what will beopend
sNewfileFormName="invoerveld20" 'is a writer form it must be in this database
'ThisDatabaseDocument 'ThisDatabaseDocument is a new constant in OOO3.0
oCurrentController=ThisDatabaseDocument.CurrentController
if ThisDatabaseDocument.FormDocuments.hasbyname(sNewfileFormName) then
' the form exist and can maybe opend
oNewformtoSee=oCurrentController.loadComponent( com.sun.star.sdb.application.DatabaseObject.FORM,sNewfileFormName,FALSE) ' or TRUE for editing the documentwait 10
else
msgbox "The does not exist and cannot be opend"
end
end if
end sub |
|
|
| Back to top |
|
 |
giga Newbie

Joined: 20 Jan 2009 Posts: 3
|
Posted: Wed Jan 21, 2009 7:25 pm Post subject: |
|
|
Forget about the CD that is only to disrepute the data base to the end user similar to some of the pc magazines cover CDs
I’ll restate what I need:
1. I need to now how to modify the open form code.
2. Where to finned the code to add to the macro e.g. the correct form name and where to insert it in to the code.
3. I need the data base to work on all computers with a fresh copy of Ooo 3.0 with no modification to the end user copy
Thank you for you help
p.s The data base is fully build except for these buttons |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Thu Jan 22, 2009 4:08 am Post subject: |
|
|
Hello
In OOobas the word form is used for
1) writerdocument
2) a form in a writerdocument what is a form as point 1
I assume you want open a form as point 1
The only thing to modify is | Code: | | sNewfileFormName="Yourname_for_form" 'is a writer form it must be in this database |
I don't under stand point 3
How to insert macros
| Code: | goto the Basic IDE
menu-->macros -->organize macros -->Openoffice basic
First the good place
what is the good place?
Close as much as possible of OOo. that make it less confusing.
But you should not close your program / form and not close the database
remember the name of your program / form
Choose the name of your program / form and in OOo 3.0 it is also the name of your database
If this is the first time you are working with macros there are no macros in existing macros click on new.
a new popup ask for a name accept the module1
Now you get a nearly blank window past your macro here. |
Romke |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Thu Jan 22, 2009 4:30 am Post subject: |
|
|
You can not embed macros in database documents. Embedded macros in databases will be introduced in version 3.1 (March 2009).
You can embed the macro in the embedded Writer document (the form document), but then the user has to turn of macro security because that storage is never part of the trusted directories.
May I suggest another (may be stupid and primitive) approach?
shopping.odb is a small demo on references and filters where I used Writer's layout capabilities to separate forms and navigate by bookmarks and hyperlinks.
You can put as many forms in the same Writer document as you like. Just use the form navigator to add new, independent forms to the "Forms" container or dependent subforms to existing forms. _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
giga Newbie

Joined: 20 Jan 2009 Posts: 3
|
Posted: Fri Jan 23, 2009 8:29 am Post subject: |
|
|
Thank you for the help RPG and Villeroy the database in almost complete
Villeroy thank for the upload
RPG thank for your help
The database is designed to help track and manage job hunting for the unemployed.
Any comment is welcome.
P.S This is my open source and free programme for the year.
The database can be downloaded from http://www.mediafire.com/?vttzbxjxl0b |
|
| Back to top |
|
 |
Hezza1506 General User

Joined: 13 Jan 2009 Posts: 32 Location: Scotland
|
Posted: Fri Jan 30, 2009 10:23 am Post subject: |
|
|
Sorry to jump in on the back of this, but I am also trying to create a button to open a new form. I tried using the code above, but I get an error coming back. What am I doing wrong?
My code is:
REM ***** BASIC *****
Sub OpenFormShowInfo
dim oCurrentController
'Variables for document that will be opened
dim sNewfileFormName
dim oNewformtoSee 'object for the new form
sNewfileFormName="MainEntryForm-ShowInfo"
'Declares form name - must be in database
'ThisDatabaseDocument
oCurrentController=ThisDatabaseDocument.CurrentController
if ThisDatabaseDocument.FormDocuments.hasbyname(sNewfileFormName) then
'the form exists and can be opened
oNewformtoSee=oCurrentController.loadComponent(com.sun.star.sdb.application.DatabaseObject.FORM,sNewfileFormName,FALSE)
else
msgbox "This form does not exist and cannot be opened"
end
end if
End Sub
When I try to run this, I get an error message saying:
BASIC runtime error. Object variable not set.
It highlights: oCurrentController=ThisDatabaseDocument.CurrentController
I thought it might have something to do with the fact that ThisDatabaseDocument was a comment rather than code, so I tried removing the ' to make it code, but then it just highlights the 'ThisDatabaseDocument' bit of the line above and says that it's already been declared differently.
Any suggestions? |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Fri Jan 30, 2009 11:47 am Post subject: |
|
|
Hello
I have read all your post. I think that you must first try the first lesson in programming and that
Print "hello world"
If you can that
try it with a button
Romke |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Fri Jan 30, 2009 12:30 pm Post subject: |
|
|
Hello
thisdatabasedocument can give an error if you have a version of OOo wihich is lower then OOo3.0
http://www.oooforum.org/forum/viewtopic.phtml?t=77885&highlight=thisdatabasedocument
This link maybe you need if you have not OOo3.0
thisdatabasedocument is something new and works only with OOo3.0.
http://www.oooforum.org/forum/viewtopic.phtml?t=78853
This link is working with OOo2.42
It was a fault of me that it was not in an earlier post
I Have make some changes in this text. There was an error in this text.
Some persons get an error with thisdatabasedocument.
As far I know there can be two reason for this error
a) your macros are on the wrong place. If so read this post :Jan 22, 2009 10:08 am
b) Your version of OOo does not support it.
I think all information is in this thread you need.
Romke |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Mon Feb 02, 2009 3:18 am Post subject: |
|
|
Hello Villeroy
I read a post from you on the other forum about the sub above.
I know this code can maybe give problems special for users who just start with programming and don't know it can be difficult.
For your information ThisDatabaseDocument is working in my version of OOo3. The macros I use, are on the same place as always. I knew the macros come on a new place but not in my version. I have search for the new place but cannot find it and believe it comes in version 3.1
I believe I use a stable version of OOo
I do use
openSUSE 10.3
Openoffice 3.0.1.2
OOO300m15(build:9379)
It can be that Novell has change it a little. I don't
Romke |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Mon Feb 02, 2009 8:00 am Post subject: |
|
|
Thank you for clarification. I had no doubt at all that your code does the job on your system somehow. We, the ordinary Sun users, will see ThisDatabaseDocument working when there is a macro container in Base documents (hopefully not Basic only). _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
|