Access 2007 Recordsets?

P

Peter R Hawkes

This code, working from an Outlook project was fine until I updated the
database to Access 2007!!

Dim objConn As ADODB.Connection
Dim rstConn As ADODB.Recordset
Dim strSQL As String

Set objConn = OpenAccessDB(strDBPath)
Set rstConn = CreateObject("ADODB.Recordset")

Function OpenAccessDB(strDBPath As String, Optional UID = "admin", Optional
PWD = "") As ADODB.Connection

Dim objADOConn As ADODB.Connection
Dim strConn As String

On Error Resume Next

Set objADOConn = CreateObject("ADODB.Connection")
objADOConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" &
strDBPath & "; " 'strConn

If (Err = 0) And (objADOConn.State = adStateOpen) Then
Set OpenAccessDB = objADOConn
Else
Set OpenAccessDB = Nothing
End If

Set objADOConn = Nothing

End Function

I now get a Run Time Error 3709, can someone either show me how 2007 opens
database and a recordset or point me to an article that will explain! Thnak
you.
strSQL = "SELECT strDomain, strActive FROM tblData ORDER BY strDomain"
rstConn.Open strSQL, objConn
 
P

Peter R Hawkes

ORIGINAL SHOULD ACTAULY READ AS FOLLOWS!!

This code, working from an Outlook project was fine until I updated the
database to Access 2007!!


Dim objConn As ADODB.Connection
Dim rstConn As ADODB.Recordset
Dim strSQL As String

Set objConn = OpenAccessDB(strDBPath)
Set rstConn = CreateObject("ADODB.Recordset")

strSQL = "SELECT strDomain, strActive FROM tblData ORDER BY strDomain"
rstConn.Open strSQL, objConn



Function OpenAccessDB(strDBPath As String, Optional UID = "admin", Optional
PWD = "") As ADODB.Connection

Dim objADOConn As ADODB.Connection
Dim strConn As String

On Error Resume Next

Set objADOConn = CreateObject("ADODB.Connection")
objADOConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" &
strDBPath & "; " 'strConn

If (Err = 0) And (objADOConn.State = adStateOpen) Then
Set OpenAccessDB = objADOConn
Else
Set OpenAccessDB = Nothing
End If

Set objADOConn = Nothing

End Function

I now get a Run Time Error 3709, can someone either show me how 2007 opens
database and a recordset or point me to an article that will explain! Thnak
you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top