Connecting Forms to Active Tables

See Also   

The ForeignForm button of an atb column or a cbo control links to the form containing the foreign atb control (see the example in Column's Foreign Properties). In order to do that, the atb needs the foreign Form object. This is done by the following steps:

To get this work, link blueshellAtDll2 to your project (using Project→References) and add the following code to your DataEnvironment:

Private WithEvents mwbcn As blueshellAtDll2.BatCon

Set mwbcn = blueshellAtDll2.GetBatCon(pConnection)

Set frm = frmCustomer

If you don't use a DataEnvironment (as in VB5 or VB6 Learning), the steps are essentially the same. In this case declare and initialize the BatCon variable WithEvents and define the event procedure in the module that declares and initializes your ADO.Connection variable. See the NWPlain.vbp example for details.

Example

Private WithEvents mwbcn As blueshellAtDll2.BatCon

Private Sub SCOTT_ConnectComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)

On Error Resume Next

Dim var1 As Variant

Set mwbcn = blueshellAtDll2.GetBatCon(pConnection)

' Initialize our BatCon object in order to receive the events

End Sub

 

Private Sub mwbcn_GetForm(nfrm As String, frm As Object) ' Give bAt the frm objects that it needs

On Error Resume Next

Select Case nfrm

Case "frmCustomer"

Set frm = frmCustomer

Case "frmDept"

Set frm = frmDept

Case "frmEmp"

Set frm = frmEmp

Case "frmOrders"

Set frm = frmOrders

Case "frmProduct"

Set frm = frmProduct

End Select

End Sub