I have a form and subform. The main form shows some customer details, and the continuous sub form shows that customer's charity donations.
The code below runs when the form opens, and binds ADO recordsets to the two forms. The binding appears to be successful.
However whatever I do I can't make the subform update correctly to show the relevant customer donations. For example, when I use the **'d lines to update the link child/master fields, I get a "Data Provider Could Not Be Initialized" error.
Any idea how I can get this to work?
The code below runs when the form opens, and binds ADO recordsets to the two forms. The binding appears to be successful.
However whatever I do I can't make the subform update correctly to show the relevant customer donations. For example, when I use the **'d lines to update the link child/master fields, I get a "Data Provider Could Not Be Initialized" error.
Any idea how I can get this to work?
Code:
Private Sub Form_Load()
Dim cn As New ADODB.Connection
Dim rsCust As New ADODB.Recordset
Dim rsDons As New ADODB.Recordset
Dim strConnect As String
strConnect = "DSN=MYSQL DSN"
cn.CursorLocation = adUseClient
cn.Open strConnect
With rsCust
Set .ActiveConnection = cn
.Source = "customer"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
With rsDons
Set .ActiveConnection = cn
.Source = "donations"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
Set Me.Recordset = rsCust
Set Me.frmCustomerDonation.Form.Recordset = rsDons
Me.frmCustomerDonation.LinkChildFields = "URN" '**
Me.frmCustomerDonation.LinkMasterFields = "URN" '**
Set rsCust = Nothing
Set rsDons = Nothing
Set cn = Nothing
End Sub