Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Records _ Compile Error In Access 2013 With Dim Recordsset

Posted by: youngb Feb 5 2019, 08:17 AM


I am getting a compile error when I compile the following code in Access 2013:

    Dim db As Database
    Dim rs As Recordset
    Dim sqlString As String
    Dim cTable As String
    Dim CONSTR As String
    Set db = CurrentDb()
    sqlString = "SELECT * "
    sqlString = sqlString & " FROM T_TABLES"
    sqlString = sqlString & " Where Update = True"
    'SqlString = SqlString & " WHERE (((T_TABLES.DataPath) Is Not Null) And ((T_TABLES.Access)=True));"
    Set rs = db.OpenRecordset(sqlString, 2)
    If rs.RecordCount > 0 Then
        MsgBox "There are no records in the T_Tables with Update  set to true"
    End If
    Do Until rs.EOF
        cTable = rs.Fields("Table")
        CONSTR = db.TableDefs(cTable).Connect
        rs![ConnectionString] = CONSTR

but if I change the line:
Dim rs As Recordset

Dim rs As DAO.Recordset

it compiles fine, did this change with Access 2013?

Thanks in Advance for any helpful suggestions


Posted by: cheekybuddha Feb 5 2019, 08:35 AM


You probably have a reference to ADO set.

This would cause confusion to the compiler about which Recordset object you want unless it is fully qualified.

If so, were you to unset it, it ought to compile.

Always better to fully qualify your recordset references to avoid this sort of confusion.




Posted by: GroverParkGeorge Feb 5 2019, 08:41 AM

Actually, I am not surprised. Later versions of Access have tightened up referencing, in my experience.

And I agree with David on the importance fully qualifying ALL of your references anyway.

Posted by: youngb Feb 5 2019, 09:21 AM


That was indeed the problem it was reference to:

Microsoft Office 15.0 Access database Engine Object Libary

so when I changed this to: '
Microsoft DAO 3.6 Object Libary
everything worked,
Think I will fully qualify in future.

Thanks Guys


Posted by: cheekybuddha Feb 5 2019, 09:42 AM


I would stick with the original library, just qualify the objects' definitions

Posted by: youngb Feb 6 2019, 03:50 AM


yes indeed, that is the original library, as you say, in future just qualify the dim statement.


Posted by: cheekybuddha Feb 6 2019, 04:53 AM

Just to be clear,

I meant stick with 'Microsoft Office 15.0 Access Database Engine Object Library',

and remove 'Microsoft DAO 3.6 Object Library'