ADO error

abenitez77

Registered User.
Local time
Today, 15:01
Joined
Apr 29, 2010
Messages
141
I get an error "type mismatch" on this line below:
Set rst = CreateObject("ADODB.Recordset")


Dim temp As String
Dim rst As Recordset
Dim db As Database

Dim strSQLServer As String
Dim strSQLDatabase As String
Dim strSQLTableName As String
Dim strLinkedTableName As String
On Error GoTo Err_cmdLinkTablesADO
Set db = CurrentDb
Set Conn = Application.CurrentProject.Connection
Set rst = CreateObject("ADODB.Recordset")
rst.OpenRecordset "SELECT * FROM tblLinkTables ORDER BY Recno", Conn
 
TRY:
Code:
    Dim temp As String
    Dim rst As ADODB.Recordset
    Dim db As Database
    
    Dim strSQLServer As String
    Dim strSQLDatabase As String
    Dim strSQLTableName As String
    Dim strLinkedTableName As String
    On Error GoTo Err_cmdLinkTablesADO
    Set db = CurrentDb
    Set Conn = Application.CurrentProject.Connection
    Set rst = NEW ADODB.recordset
    rst.OPEN "SELECT * FROM tblLinkTables ORDER BY Recno", Conn
 
I get an error "type mismatch" on this line below:
Set rst = CreateObject("ADODB.Recordset")


Dim temp As String
Dim rst As Recordset
Dim db As Database
If you are going to use CreateObject you might as well go all the way with late binding and just use

Dim rst As Object

and then it doesn't matter.

You don't need the Dim db part though as you are never using it. That is for DAO and not ADO.
 
Bob,

that reminds me. I always wanted to ask a professional this: Can you use the SET statement on a variable that isn't declared?

I have a habit of not requiring Option Explicit, and I know through testing that you can't use an undeclared variable in a FOR loop. It throws an error, even without Opt. Expl.
 
Hello

I have a similiar problem. I have a access project that runs on several computers with diferent operating systems. On a computer (that has Windows Vista and Office 2007) I receive a error message (type mismatch) and the line of code that throws this error message is the line where I set the connection. I've place the code bellow:

Code:
Dim cn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim sql As String
Set cn = Application.CurrentProject.Connection 'this is the line that throws the error message
Set rst = New ADODB.Recordset
This problem started a few days ago and only on that particular computer. Did anyone else encounter this particular problem?
 
1. ADO is installed by Windows and the MDAC (Microsoft Data Access Components).

2. So it is version specific to the version of Windows you have. So if you set the reference to 2.8 (which comes with Windows 7) then anyone with 2.7 or less will have a reference problem.

So, make sure, to keep compatibility, with other Operating Systems, that you use 2.6 which is from Windows XP and then you shouldn't have a problem.
 

Users who are viewing this thread

Back
Top Bottom