Implementing Interfaces on Forms

Implementing Interfaces on Forms

There is an easy way to make your application respond to data changes in forms, by implementing interfaces on your forms.For example, when you have an order application and insert, change or delete a customer, you want the customer combobox on all open order forms to be updated. Here is the code:

 'IEvent - Class modulePublic Enum AppEvents    aeCustomerInsert    aeCustomerUpdate    aeCustomerDeleted    aeOrderInsert    aeOrderUpdate    aeOrderDeletedEnd EnumPublic Function AppEvent(RaisedEvent As AppEvents, _                         Optional Value1 As Variant, _                         Optional Value2 As Variant, _                         Optional Value3 As Variant, _                         Optional Value4 As Variant, _                         Optional Value5 As Variant)End Function'frmCustomer - Customer formPrivate Sub cmdSave_Click()Dim frmForm As FormDim vEvent As IEvent    For Each frmForm In Forms        If TypeOf frmForm Is IEvent Then            Set vEvent = frmForm            vEvent.AppEvent aeCustomerUpdate        End If    NextEnd Sub'frmOrder - Order FormImplements IEventPrivate Sub Form_Load()    LoadCustomerComboEnd SubPrivate Function IEvent_AppEvent(RaisedEvent As AppEvents,                                 Optional Value1 As Variant,                                 Optional Value2 As Variant,                                 Optional Value3 As Variant,                                 Optional Value4 As Variant,                                 Optional Value5 As Variant) As Variant    Select Case RaisedEvent    Case aeCustomerInsert, aeCustomerUpdate, aeCustomerDeleted        LoadCustomerCombo    End SelectEnd Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several