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

Hi,

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


CODE
    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
        rs.MoveFirst
    Else
        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.Edit
        rs![ConnectionString] = CONSTR
        rs.Update
        rs.MoveNext
    Loop




but if I change the line:
CODE
Dim rs As Recordset


To:
CODE
Dim rs As DAO.Recordset


it compiles fine, did this change with Access 2013?


Thanks in Advance for any helpful suggestions

Brian


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

Hi,

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.

thumbup.gif

hth,

d

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

Hi,



That was indeed the problem it was reference to:

QUOTE
Microsoft Office 15.0 Access database Engine Object Libary


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

Thanks Guys

Regards
Brian

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

Hmm....

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

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

Hi,

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

Brian

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'