Calling a Method using a Property.Value

Greetings. Noob now committed to a tool change.

Have 3 windows. Think of a generic Notes window attached to various table/records)

WindowCustomer has a listbox
it is managed by a method “manageNOTES” in which everything from building recordset to creating new NOTES is controlled.

WindowSupplier has a listbox
it is managed by a method “manageNOTES” in which everything from building recordset to creating new NOTES is controlled.

WindowNotes gets launched by either Windows.listbox.dclick event (etc.) and is controlled by either Windows.method.manageNOTES
WindowNotes.property.lvControlledby='WindowCustomer.manageNOTES" is set when launched from WindowCustomer
WindowNotes.property.lvControlledby='WindowSupplier.manageNOTES" is set when launched from WindowSupplier

When something like a navigate to next record is performed in WindowNotes , I’d like to call something like lvControlledby
Presently something like this works, but lots of coding redirects …

select case lvControlledby
case If = “WindowCustomer.manageNOTES” Then WindowCustomer.manageNOTES(“navNext”)
case if = “WindowSupplier.manageNOTES” Then WindowSupplier.manageNOTES(“navNext”)
case if = …
end

Any thoughts or did I lose you at hello :).

Yeah dont do that this way :stuck_out_tongue:

You should have an interface - NotesManagerInterface
And then two classes that implement this interface - “SupplierNotesManager” and a “CustomerNotesManager”
And then your property is a reference to an instance of a NotesManager and you can call the methods on that without having to do any select case / if then else etc

And since the ONLY requirement is that you attach the right kind of notes manager to whatever window you dont have really tight coupling

Thanks for the reply and Happy New Year!

Obviously more reading/testing required …

Don’t quite know what the advantage would be as would have to create a Class within WindowNotes for every “interface” which which interacts with it (Customers,Sales,Payments,Employees,Contacts,etc …)

Presently I have 1 common method which evaluates the passed parameter and redirects to the controlling window - so 1 case condition for each “interface”. Sounds like the same amount of work and conditioning.

Or am I just being an old-style dinosaur once again ?

You create one class of type NotesManagerInterface in WindowNotes. Every “Manager” (Customers, Sales, Payments, Employees, Contacts, etc.) must implement the NotesManagerInterface and then can be assigned to this one class of NotesManagerInterface in WindowNotes.