| View previous topic :: View next topic |
| Author |
Message |
cazbym Power User

Joined: 16 Mar 2009 Posts: 63
|
Posted: Mon Mar 26, 2012 4:41 am Post subject: Standalone Form Filtering to Another Standalone Form |
|
|
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 |
|
 |
cazbym Power User

Joined: 16 Mar 2009 Posts: 63
|
Posted: Wed Mar 28, 2012 12:38 am Post subject: Standalone Forms Filtering to Other Standalone Form - Macro |
|
|
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!!
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 |
|
 |
|