Can anyone find my mistake?
I'm using the following code to create one of two possible recordsets, depending on the value in another form. This is using an SQL7 database via ADO. The first possibility (Shop Orders) works fine; the second continually gives me "Item cannot be found in the collection corresponding to the requested name or ordinal". It fails on the "open" statement. Using Query Analyzer, I can run the Stored Proc (sel_styles) and it works fine. Can anyone figure this out???
Code:
Dim rsListing As New ADODB.Recordset
Dim objCmd As ADODB.Command
Set objCmd = New ADODB.Command
With objCmd
.ActiveConnection = PROJ_DB
.CommandType = adCmdStoredProc
If frmShopOrder2.txtShopOrderNo = "?" Then
.CommandText = "sel_shoporder"
ElseIf frmShopOrder2.txtStyle = "?" Then
.CommandText = "sel_styles"
End If
End With
With rsListing
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Open objCmd
End With
Set objCmd = Nothing