Yes, they work perfectly. Here a piece of code that I've taken from the
web many years ago; so pardon me if I cannot give you the full reference:
Public Function DAODatabase() As DAO.Database
Dim cnn As ADODB.Connection
Dim dbDAO As DAO.Database
Dim strConnect As String
Set cnn = CurrentProject.Connection
' Is the connection based on MSdataShape- or SQLOLEDB-provider?
If InStr(cnn.Provider, "Microsoft.Access.OLEDB") > 0 Or
InStr(cnn.Provider, "MSDataShape") > 0 Or InStr(cnn.Provider, "SQLOLEDB") >
0 Then
' Build connection string
strConnect = "ODBC;driver=SQL Server;server=" & cnn.Properties("Data
Source") & ";"
' Database Name
strConnect = strConnect & "database=" & cnn.Properties("Initial
Catalog") & ";"
' SQL Server- or Windows-security?
If cnn.Properties("Integrated Security") = "SSPI" Then
strConnect = strConnect & "Trusted_Connection=Yes;"
Else
strConnect = strConnect & "UID=" & cnn.Properties("User ID") &
";"
strConnect = strConnect & "PWD=" & cnn.Properties("Password") &
";"
End If
Else
MsgBox "DAO-Database not opened!"
Set DAODatabase = Nothing
Exit Function
End If
' Open Database
Set dbDAO = DBEngine.OpenDatabase("", False, False, strConnect)
Set DAODatabase = dbDAO
End Function
Sub DAO_Test()
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = DAODatabase()
Set rec = db.OpenRecordset("select * from tblFilme", dbOpenForwardOnly)
Do Until rec.EOF
Debug.Print rec!Filmtitel
rec.MoveNext
Loop
Set db = Nothing
End Sub
If you want to have transactions, you can also first open a Workspace.
Also, after taking a quick look at it, maybe it will be a good idea to
explicitely close the database before setting to Nothing.