snakehips2000
Programmer
I'm trying to populate a form with the results of an ADO recordset which itself is based on a stored procedure.
Can someone please tell me why this code returns the message "Object variable not set" when it gets to the final line?
I've tried putting the routine both in a form module and public module.
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = MyConnectionString
cn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseServer
rs.CursorType = adOpenDynamic
rs.Open "EXEC " & StoredProcedureName, cn, adopenstatic, adLockoptimistic
'Assign to form
Me.Recordset = rs
Thanks.
Can someone please tell me why this code returns the message "Object variable not set" when it gets to the final line?
I've tried putting the routine both in a form module and public module.
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = MyConnectionString
cn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseServer
rs.CursorType = adOpenDynamic
rs.Open "EXEC " & StoredProcedureName, cn, adopenstatic, adLockoptimistic
'Assign to form
Me.Recordset = rs
Thanks.