a) When you have used Microsoft Office
b) Have never used before OpenOffice.org
c) Have used an other office suite.
d) Have not read an tutorial about OpenOffice.
I think this is nearly for all people. To much people start working with OOo without understanding it. Opening a form is different for standalone forms and for forms embedded in a database. Opening forms without macros is real easy when you use standalone forms. You can do this with insert a hyperlink to an other form. When you use this method you can also pass parameters to other forms. Villeroy and now also Arineckaig are working with forms and databases without using macros.
When you want open a form what is not a standalone form then you need a macro or you have to use the switchboard extension of Benitez.
You can see it is real eay to open a form. You need only this line:
Code: Select all
ThisDatabaseDocument.FormDocuments.getbyname(sNewDocumentName).open
Code: Select all
thisDatabaseDocument.FormDocuments.getByHierarchicalName("SubPlantsMap/SelectedPlants").open
I hope other people can open this database there I have always to connect to the class. In the database there is also an example where I do a lot of testing on names. When the names are wrong you get a message.
Romke
Code: Select all
REM ***** BASIC *****
option explicit ' I use this line always Then I must define variables.
' I do use several methods for opening a form.
' a) a normal standard opening for a form.
' b) Use a selected value for opening a form .In the new form we use this
' selected value for selecting records.
' c) Using the Basetools
' d) I use here the getByHierarchicalName property for opening a form
' All are activate with a button and then
'This module is using real short code there isno testing.
' The short code makes it more clear what happens
sub OpenForm_1
const sNewDocumentName="Plants" ' This is the variabele for the new form what must be opened
' Use this for opening a data form
ThisDatabaseDocument.FormDocuments.getbyname(sNewDocumentName).open
end sub
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
sub OpenForm_2(oEvent)
const sNewDocumentName="Plants" ' This is the variabele for the new form what must be opened
' This sub is activated by a button in a form
' First define all variables which we need for the form where the button is.
dim oButton, oForm,oGrid,oControl ' This are the objects for the control who I need
' Now define the names in the form where the button is.
' Adjust the names to your need
const sGridName="Table Control 1"
const sControlName="TextField2"
' we want have a text control in a gridcontrol
'Now define all the variables who we need in the form we want open.
dim oNewFormDocument,oNewDataForm
dim sSearchValue
const sNewFormname="PlantsForm" ' The form name as you see in the form navigator
const sSearchfield="Name" ' Change the name between the double quote according in your table.
' Now start the program
oButton=oEvent.source.model ' Now I have the button. Which is in a form.
oForm=oButton.parent ' the value must be in this form.
' Now locate your control. and test for the names
oGrid=oForm.getbyname(sGridName) ' First the grid control
oControl=oGrid.getbyname(sControlName) ' Now the text control in a grid
' Now the action for the new form
' we want have a value from a grid table
' Go for the object of the subdocument
' Use this for opening a data form
oNewFormDocument=ThisDatabaseDocument.FormDocuments.getbyname(sNewDocumentName).open
oNewDataForm=oNewFormDocument.drawpage.forms.getbyname(sNewFormname)
' We want filter the new form
dim sFilter
sFilter= chr(34) & sSearchfield & chr(34) & CHR(61)& chr(39) & oControl.TEXT & chr(39)
oNewDataForm.filter=sFilter
oNewDataForm.applyfilter=true
oNewDataForm.reload
end sub
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' In this sub we use:
' A) a selected value for selecting records
' B) The Basetools
sub OpenForm_3(oEvent as object)
' This sub is activated by a button in a form
' First define all variables which we need for the form where the button is.
dim oButton, oForm,oGrid,oControl ' This are the objects for the control who I need
' Now define the names in the form where the button is.
' Adjust the names to your need
const sGridName="Table Control 1"
const sControlName="TextField2"
'Now define all the variables who we need in the form we want open.
dim sSearchValue
const sNewDocumentName="Plants" ' This is the variabele for the new form what must be opened
'const sNewFormname="PlantsForm" ' The form name as you see in the form navigator
const sSearchfield="Name" ' Change the name between the double quote according in your table.
' Now start the program
oButton=oEvent.source.model ' Now I have the button. Which is in a form.
oForm=oButton.parent ' the value must be in this form.
' oControl=oForm.getbyname(sControlName) ' when you use a control not in a grid
oGrid=oForm.getbyname(sGridName)
oControl=oGrid.getbyname(sControlName)
print "basetools without contrl"
' Now we start using the Basetools
' First make sure the library is loaded
if not globalscope.BasicLibraries.islibraryloaded("BaseTools") then
' Load now the library
globalscope.BasicLibraries.loadlibrary("BaseTools")
end if
' We want filter the new form
dim sFilter
sFilter= chr(34) & sSearchfield & chr(34) & CHR(61)& chr(39) & oControl.TEXT & chr(39)
DIM oNewDataForm
databases.InitFromDocument thisdatabasedocument ' We need this
' Explanation of the parameter
' The name of the formdocument we want open.
' The event of a button i did use
oNewDataForm=runcmd.openFormDocument(sNewDocumentName,oEvent,sFilter) ' I do get the data form not document.
oNewDataForm.reload ' I need this instruction I don't know if it is normal
end sub
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
sub OpenForm_4(oEvent)
const sNewDocumentName="SubPlants/SubPlants" ' This is the variabele for the new form what must be opened
' This sub is activated by a button in a form
' First define all variables which we need for the form where the button is.
dim oButton, oForm,oGrid,oControl ' This are the objects for the control who I need
' Now define the names in the form where the button is.
' Adjust the names to your need
const sGridName="Table Control 1"
const sControlName="TextField2"
' we want have a text control in a gridcontrol
'Now define all the variables who we need in the form we want open.
dim oNewFormDocument,oNewDataForm
dim sSearchValue
const sNewFormname="PlantsForm" ' The form name as you see in the form navigator
const sSearchfield="Name" ' Change the name between the double quote according in your table.
' Now start the program
oButton=oEvent.source.model ' Now I have the button. Which is in a form.
oForm=oButton.parent ' the value must be in this form.
' Now locate your control. and test for the names
oGrid=oForm.getbyname(sGridName) ' First the grid control
oControl=oGrid.getbyname(sControlName) ' Now the text control in a grid
' Now the action for the new form
' we want have a value from a grid table
' Go for the object of the subdocument
' Use this for opening a data form
oNewFormDocument=ThisDatabaseDocument.FormDocuments.getByHierarchicalName(sNewDocumentName).open
oNewDataForm=oNewFormDocument.drawpage.forms.getbyname(sNewFormname)
' We want filter the new form
dim sFilter
sFilter= chr(34) & sSearchfield & chr(34) & CHR(61)& chr(39) & oControl.TEXT & chr(39)
oNewDataForm.filter=sFilter
oNewDataForm.applyfilter=true
oNewDataForm.reload
end sub