Hello,
I finally decided to switch from DAO to ADO but I ran across a weird problem when trying to create a Query :
Here is the code
Sub CreateQuery()
Dim catCurr As New ADOX.Catalog
Dim cmdcurr As New ADODB.Command
catCurr.ActiveConnection = CurrentProject.Connection
cmdcurr.CommandText = "Select * From MyTable"
catCurr.Procedures.Append "qry", cmdcurr
End sub
Sub ListQuery()
Dim catCurr As New ADOX.Catalog
Dim cmdcurr As ADODB.Command
Dim rec As New ADODB.Recordset
catCurr.ActiveConnection = CurrentProject.Connection
Set cmdcurr = catCurr.Procedures("qry"
.Command
rec.Open cmdcurr, , adOpenStatic, adLockPessimistic
Debug.Print rec.GetString
End Sub
This is very simple code but when I run the red line I get a run-time error 3265 (Item cannot be found in the collection corresponding to the requested name or ordinal).
Of course I ran the procedure CreateQuery first.
Another odd thing is that after I call CreateQuery catCurr.Procedure.Count returns 1 and after I call ListQuery it returns 0!? But if I try to re-run CreateQuery it get the error "Object Already Exists"
Thanx for the help.
I finally decided to switch from DAO to ADO but I ran across a weird problem when trying to create a Query :
Here is the code
Sub CreateQuery()
Dim catCurr As New ADOX.Catalog
Dim cmdcurr As New ADODB.Command
catCurr.ActiveConnection = CurrentProject.Connection
cmdcurr.CommandText = "Select * From MyTable"
catCurr.Procedures.Append "qry", cmdcurr
End sub
Sub ListQuery()
Dim catCurr As New ADOX.Catalog
Dim cmdcurr As ADODB.Command
Dim rec As New ADODB.Recordset
catCurr.ActiveConnection = CurrentProject.Connection
Set cmdcurr = catCurr.Procedures("qry"
rec.Open cmdcurr, , adOpenStatic, adLockPessimistic
Debug.Print rec.GetString
End Sub
This is very simple code but when I run the red line I get a run-time error 3265 (Item cannot be found in the collection corresponding to the requested name or ordinal).
Of course I ran the procedure CreateQuery first.
Another odd thing is that after I call CreateQuery catCurr.Procedure.Count returns 1 and after I call ListQuery it returns 0!? But if I try to re-run CreateQuery it get the error "Object Already Exists"
Thanx for the help.