Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Command Object Error in Access 2002 VBA

Status
Not open for further replies.

Giraffe69

Programmer
Oct 7, 2003
22
GB
I've got this bit of code in a VBA module:
Code:
Sub test()
    Dim c As ADODB.Connection
    Dim m As ADODB.Command
    Dim r As ADODB.Recordset
    Set c = New ADODB.Connection
    With c
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb;User Id=Admin;Password="
        .ConnectionTimeout = 10
        .CursorLocation = adUseServer
        .Open , , , adAsyncConnect
    End With
    With m
[COLOR=red]        .ActiveConnection = c[/color]
        .CommandType = adCmdText
        .CommandText = "select x from tblTable1"
    End With
    r.Open c, , adOpenDynamic, adLockReadOnly, adCmdText
End Sub

But, the line:
.ActiveConnection = c
is generating the error:
Run-time error '3709':
Requested operation requires an OLE DB Session object, which is not supported by the current provider

I've run code similar to this before with no problems. Any advice would be appreciated!
 
Perhaps this ?
Set .ActiveConnection = c

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
that works, thanks PHV.
I'm really embarrassed..... ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top