T
Tony Nichols
I have written exact code in Access 2000 that I have in Access 97 using the
DAO and receive an error 13 'Type mismatch' when the recordset object is
being initiated.
I tried converting a test db from Access97 to Access 2000 and the code
worked fine.
Can anyone tell me what I have to do to use the DAO in Access 2000 and not
have problems. It seems the conversion wizard makes some changes to allow
the code to work but I cannot determine what the changes are.
I have posted the code below:
Public Sub DeleteProd()
Dim db As Database
Dim rec As Recordset
Dim sMsg As String
On Error GoTo ErrHandler
Set db = CurrentDb()
Set rec = db.OpenRecordset("SalesTotalOld", dbOpenDynaset)
With rec
.MoveLast
.MoveFirst
Do Until .EOF
.Delete
.MoveNext
Loop
End With
rec.Close
db.Close
Set rec = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
Select Case Err.Number
Case 3218, 3021
Resume
Case Else
sMsg = "Error " & Err.Number & " " & Err.Description
MsgBox sMsg, vbOKOnly, "Error"
Exit Sub
End Select
End Sub
Thanks,
Tony Nichols
DAO and receive an error 13 'Type mismatch' when the recordset object is
being initiated.
I tried converting a test db from Access97 to Access 2000 and the code
worked fine.
Can anyone tell me what I have to do to use the DAO in Access 2000 and not
have problems. It seems the conversion wizard makes some changes to allow
the code to work but I cannot determine what the changes are.
I have posted the code below:
Public Sub DeleteProd()
Dim db As Database
Dim rec As Recordset
Dim sMsg As String
On Error GoTo ErrHandler
Set db = CurrentDb()
Set rec = db.OpenRecordset("SalesTotalOld", dbOpenDynaset)
With rec
.MoveLast
.MoveFirst
Do Until .EOF
.Delete
.MoveNext
Loop
End With
rec.Close
db.Close
Set rec = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
Select Case Err.Number
Case 3218, 3021
Resume
Case Else
sMsg = "Error " & Err.Number & " " & Err.Description
MsgBox sMsg, vbOKOnly, "Error"
Exit Sub
End Select
End Sub
Thanks,
Tony Nichols