I have a subform connected to a stored procedure in SQL Server. I can sort it once, but when I try to sort it a second time I get an error 'Data provider could not be initialized'.
The code to link the subform to the stored procedure is:
Any ideas on how to fix this?
The code to link the subform to the stored procedure is:
Code:
Private Sub Form_Current()
Dim com As ADODB.Command
Dim rst As ADODB.Recordset
Set com = New ADODB.Command
With com
.ActiveConnection = CONNECTION
.ActiveConnection.CursorLocation = adUseClient
.CommandText = "spCorpGroupOrgStructure"
.CommandType = adCmdStoredProc
.Parameters.Refresh
.Parameters("@intOwnedCompanyID") = Me.intCompanyID
Set Forms!frmCorpGroupOwnership.[Owned Companies].Form.Recordset = .Execute
End With
End Sub
Comment