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

Standalone Form Filtering to Another Standalone Form

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
cazbym
Power User
Power User


Joined: 16 Mar 2009
Posts: 63

PostPosted: Mon Mar 26, 2012 4:41 am    Post subject: Standalone Form Filtering to Another Standalone Form Reply with quote

Hi,

I have been trying to adapt a macro supplied on this forum by dacm 'OpenFormFilter4' to link two forms.

I have two forms: "CashBook" and "VIEW_Transactions" as named in the Forms section of my .odb

The host form "CashBook" consists of a main form and subform with a Table Control.
In Form Navigator: MainForm - SubForm - TableControl.

The field I wish to filter on is a text field whose control property name is "TxtTransID" in the subform table . The data is the Primary Key "TransID" of a table "Transactions" ie not a list box.

The form I wish to filter on "VIEW_Transactions" has a main form with a table control and a subform with a table control.

The MainForm (MainForm) contains a Table (MainForm_Grid) which contains a field "TransID" whose property name is also "TransID". I am trying to filter the main form.

I have created a pushbutton in the subform of my host form and assigned the macro to the Execute action event.

Code:


Sub OpenFormFilter_4 (oEvent As Object) 'assign this macro to Push Button > Events > Execute
   oForm = oEvent.Source.Model.Parent
   iID=oForm.getByName("Table Control").getByName("TxtTransID").text
   ThisDatabaseDocument.FormDocuments.getByName("VIEW_Transactions - MainForm - MainForm_Grid").close
   oForm2 = ThisDatabaseDocument.FormDocuments.getByName("VIEW_Transactions")
   oForm2.Open
   oForm3 = oForm2.Component.DrawPage.Forms.getByName("MainForm")
   oForm3.Filter="( ""VIEW_Transactions"".""TransID"" = " & iID & " )"
   oForm3.ApplyFilter=True
   oForm3.Reload()
End Sub



This falls over at iID=oForm.getByName - no such element exception.


Last edited by cazbym on Wed Mar 28, 2012 1:08 am; edited 1 time in total
Back to top
View user's profile Send private message
cazbym
Power User
Power User


Joined: 16 Mar 2009
Posts: 63

PostPosted: Wed Mar 28, 2012 12:38 am    Post subject: Standalone Forms Filtering to Other Standalone Form - Macro Reply with quote

I found the error. I mistakenly assumed that the line

Code:

ThisDatabaseDocument.FormDocuments.getByName("Address - SubForm - Text Box").close


was a hierarchy of some sort, then realised that it was the actual name of the Form!!Rolling Eyes

Have now corrected in my macro and all runs well from a Database Form to open and filter 2nd Database Form. Thankyou dacm.

I am now trying to convert this to work with standalone documents linked to the database, and so far have this:

Code:

Sub   OpenFormFilter_4 (oEvent As Object) 'assign this macro to Push Button > Events > Execute
   oForm = oEvent.Source.Model.Parent 'get the host Form object from the Push Button's Execute Event
   iID=oForm.getByName("TableControl").getByName("TransID").text
   cFile = "C:\Users\Public\Documents\LCE FORMS\VIEW_Transactions.odt"
   cUrl = ConvertToURL( cFile )
   oForm2 = StarDesktop.loadComponentFromURL( cUrl, "_blank", 0, Array() ).close
   oForm2.Open
   oForm3 = oForm2.Component.DrawPage.Forms.getByName ("MainForm")
   oForm3.Filter="( ""Transactions"".""TransID"" = " & iID & " )"
   oForm3.ApplyFilter=True
   oForm3.Reload()
End Sub


I get an "Illegal argument exception - argument lens differ" on line "oForm2=StarDesktop.....", but it does open a blank copy of my file. All files are in the same folder "LCE FORMS" in my file system

I keep reading stuff but am not getting any brighter. I have read Andrew Pitonyak's doc and looked at the threads here regarding URLs but am none the wiser. I am sure lots of non coders like me would want this macro.

Can anyone tell me what I am doing wrong?
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 Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
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