R
Rob Lindman
I'm attempting to run a bit of module code from a form. The code basically
creates a text file of a set of records, but does other things that force
use of code instead of a macro or other method.
Sometimes it works, sometimes it doesn't, and I'm certain it has something
to do with how I'm connecting to the database.
Sub ExampleForNewsgroup()
Dim Conn As ADODB.Connection
Dim RS As ADODB.Recordset
Set Conn = New ADODB.Connection
Set RS = New ADODB.Recordset
sDBPath = CurrentDb.Name
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & sDBPath & ";"
sql = "select blah blah" ' paraphrase
RS.Open sql, conn, blah blah ' paraphrase
End Sub
The code sometimes chokes on the Conn.Open line, claiming that the database
is in a state that it can't opened or be locked.
I know this is common, can anyone quickly bust out with different syntax for
connecting to the current database using ADO?
Thanks in advance.
creates a text file of a set of records, but does other things that force
use of code instead of a macro or other method.
Sometimes it works, sometimes it doesn't, and I'm certain it has something
to do with how I'm connecting to the database.
Sub ExampleForNewsgroup()
Dim Conn As ADODB.Connection
Dim RS As ADODB.Recordset
Set Conn = New ADODB.Connection
Set RS = New ADODB.Recordset
sDBPath = CurrentDb.Name
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & sDBPath & ";"
sql = "select blah blah" ' paraphrase
RS.Open sql, conn, blah blah ' paraphrase
End Sub
The code sometimes chokes on the Conn.Open line, claiming that the database
is in a state that it can't opened or be locked.
I know this is common, can anyone quickly bust out with different syntax for
connecting to the current database using ADO?
Thanks in advance.