I am using an ADODB.recordset to display data on a form (microsoft access 2000). This recordset needs to get its data from an SQL server 2000 stored procedure.
I do this in the on_open event of the form so that the data is displayed when you open the form.
I must be able to write to the recordset (using code on the form).
I have used the following code. My connection seems to work but the recordset doesn't seem to open. I get a "recordset not open" error on the line that says "While not .eof"
Private Sub Form_Open(Cancel As Integer)
'CREATE CONNECTION
Dim ado_conn As ADODB.Connection
Dim strServer, strDbase As String
Set ado_conn = New ADODB.Connection
strServer = "myserver"
strDbase = "myDB"
ado_conn.ConnectionTimeout = 15
ado_conn.Provider = "SQLOLEDB"
ado_conn.Properties("Data Source".Value = strServer
ado_conn.Properties("Initial Catalog".Value = strDbase
ado_conn.Properties("Integrated Security".Value = "SSPI"
ado_conn.Properties("User ID".Value = "UserName"
ado_conn.Properties("PassWord".Value = "Password"
ado_conn.Open
'CREATE RECORDSET
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Source = "sp_jonsproc " _
& [Forms]![client menu]![client details]![ID No]
Set rst.ActiveConnection = ado_conn
rst.Open
With rst
While Not (rst.EOF)
'!Balance = !balance * 10
.MoveNext
Wend
'Display the recordset on the form.
Set Me.Recordset = rst
End With
End Sub
I do this in the on_open event of the form so that the data is displayed when you open the form.
I must be able to write to the recordset (using code on the form).
I have used the following code. My connection seems to work but the recordset doesn't seem to open. I get a "recordset not open" error on the line that says "While not .eof"
Private Sub Form_Open(Cancel As Integer)
'CREATE CONNECTION
Dim ado_conn As ADODB.Connection
Dim strServer, strDbase As String
Set ado_conn = New ADODB.Connection
strServer = "myserver"
strDbase = "myDB"
ado_conn.ConnectionTimeout = 15
ado_conn.Provider = "SQLOLEDB"
ado_conn.Properties("Data Source".Value = strServer
ado_conn.Properties("Initial Catalog".Value = strDbase
ado_conn.Properties("Integrated Security".Value = "SSPI"
ado_conn.Properties("User ID".Value = "UserName"
ado_conn.Properties("PassWord".Value = "Password"
ado_conn.Open
'CREATE RECORDSET
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Source = "sp_jonsproc " _
& [Forms]![client menu]![client details]![ID No]
Set rst.ActiveConnection = ado_conn
rst.Open
With rst
While Not (rst.EOF)
'!Balance = !balance * 10
.MoveNext
Wend
'Display the recordset on the form.
Set Me.Recordset = rst
End With
End Sub