Hi,
I'm trying to use DAO in execl to pull some records from a database. I can do this no probs using ADO but when I use DAO (3.6) I get a data mis-match error. The code I'm using is below and the problem occurs at the populate recordset line.
Anybody help?
Thanx
Sub dbquery()
Dim myDatabase As Database
Dim strSQL As String
Dim rstFromQuery As Recordset
'open database
myDatabase = OpenDatabase("C:mydatabase.mdb")
' build query
strSQL = "SELECT * from myTable"
'populate recordset
Set rstFromQuery = myDatabase.OpenRecordset(strSQL, dbOpenSnapshot)
'display records
MsgBox "there are " & rstFromQuery.RecordCount & _
" records that were returned"
rstFromQuery.MoveLast
MsgBox "there are " & rstFromQuery.RecordCount & _
" records that were returned"
rstFromQuery.Close
End Sub
I'm trying to use DAO in execl to pull some records from a database. I can do this no probs using ADO but when I use DAO (3.6) I get a data mis-match error. The code I'm using is below and the problem occurs at the populate recordset line.
Anybody help?
Thanx
Sub dbquery()
Dim myDatabase As Database
Dim strSQL As String
Dim rstFromQuery As Recordset
'open database
myDatabase = OpenDatabase("C:mydatabase.mdb")
' build query
strSQL = "SELECT * from myTable"
'populate recordset
Set rstFromQuery = myDatabase.OpenRecordset(strSQL, dbOpenSnapshot)
'display records
MsgBox "there are " & rstFromQuery.RecordCount & _
" records that were returned"
rstFromQuery.MoveLast
MsgBox "there are " & rstFromQuery.RecordCount & _
" records that were returned"
rstFromQuery.Close
End Sub