I have an Access ADP file. I upgraded the back-end database to point to a SQL 2005 server instead of a SQL 2000 server and changed the database connection information appropriately. The file runs perfectly fine on my own system, running Windows 7 (64-bit) and Access 2007. On the target systems running Windows XP and Access 2007, the primary functionality of the database blows up almost immediately with a "Run-time error '13': Type Mismatch" error.
At first I thought I was suffering from the same problem as described in this question over here, where the default definition of a connection is DAO but the database is using an ADO object. However, in reviewing the code, every instance of a connection is specifically declared as "ADODB.Connection".
The code in question that causes the error is this:
Public Sub Tools()
dim db as ADODB.Connection
dim sql as String
sql = "Select SSPatch from tblPlastech"
set db = CurrentProject.Connection ' THIS LINE CAUSES THE TYPE MISMATCH ERROR
dim rst as ADODB.RecordSet
set rst = New ADODB.RecordSet
rst.open sql, db, adOpenKeyset, adLockOptimistic
gsSSpath = rst!sspath
QUOTES = Chr(34)
rst.Close
set rst = Nothing
db.Close
set db = Nothing
End Sub
Can anyone shed a bit of light on the issue? Right now I'm stumped.
rst.open sql, db, adopenkeyset, adlockoptimistic
withrst.open sql, currentproject.connection, adopenkeyset,adlockoptimistic
? Does that trigger the same error? – Chuchuah