
Type mismatch, run-time error #13
Quote:
>Why do I get a type mismatch with this set of code????
> Dim dbsSPAM As Database
> Dim rstAuditTrail As Recordset
> Dim strTable As String
> Set dbsSPAM = CurrentDb
> strTable = "Audit Trail Table"
> Set rstAuditTrail = dbsSPAM.OpenRecordset(strTable, dbOpenTable)
>Vic
Vic
If you mean that you are getting an error on the line 'Set rsAuditTrail=...'
and are using A2K, then this is because although you have a reference to DAO in
your database, you still have a reference to ADO. Unfortunately, both of these
Object Libraries have a Recordset object, with different properties, and as you
have not told Access which one it is, it is assuming that it is the higher one
in the list of references, ie ADO.
To fix, either remove the reference to ADO if you are not going to use ADO (why
keep something that you're not going to use), or else explicitly declare
objects where appropriate:
Dim rsADO As ADODB.Recordset
Dim rsDAO As DAO.Recordset
Jon
Access tips & tricks - http://www.applecore99.com
Microsoft Access webring -
http://nav.webring.yahoo.com/hub?ring=microsoftaccess