I have two tables, Customers and Vehicles. The Customers table has a primary key, CustomerID. The Vehicles table has a primary key, ID. One customer can have more than one vehicle. I have created a form where I can select a customer, which then displays the vehicles belonging to that customer. I select a vehicle and click a Push Button to run a macro that opens a new form with customer and vehicle details.
Here's the macro:
Code: Select all
Sub OpenFormMaintDetail
const sNewDocumentName="MaintDetail"
Doc = StarDesktop.CurrentComponent
Form = Doc.DrawPage.Forms.GetByIndex(0)
CustID = Form.getByName("TxtCustID").Text
frm_container = ThisDatabaseDocument.FormDocuments.getByName(sNewDocumentName)
frm_container.open
FormModel2 = frm_container.component.DrawPage.forms.getbyindex(0)
FormModel2.Filter =("Customers.CustomerID = " & CustID)
FormModel2.ApplyFilter = True
FormModel2.reload()
end sub