Simple question

Southern Prince

New member
Local time
Today, 18:08
Joined
Sep 22, 2006
Messages
7
How do I open the current db connection using ADO?

Thanks in advance...
 
Code:
Dim cnn As ADODB.Connection

Set cnn = CurrentProject.Connection
 
Hey thanks...

Is this necessary?

Code:
   Set cn = CurrentProject.Connection
            cn.CursorLocation = adUseClient
            cn.Open

I keep getting "Operation is not allowed when object is open". It highlights cn.Open
 
Last edited:
nope

you can then use
Code:
Dim cnn As ADODB.Connection
Dim rst as ADODB.Recordset

Set cnn = CurrentProject.Connection
Set rst=New ADODB.Recordset

rst.Open "MyTableNameHere", cnn, adOpenDynamic, adLockOptimistic

to get a recordset.

You can change the adOpenDynamic to whatever of the 4 options you need for your cursor and also the same with adLockOptimistic for the locks.
 

Users who are viewing this thread

Back
Top Bottom