UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Compile Error In Access 2013 With Dim Recordsset, Access 2013    
 
   
youngb
post Feb 5 2019, 08:17 AM
Post#1



Posts: 579
Joined: 2-September 03
From: Galway, Ireland


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

Go to the top of the page
 
cheekybuddha
post Feb 5 2019, 08:35 AM
Post#2


UtterAccess VIP
Posts: 11,424
Joined: 6-December 03
From: Telegraph Hill


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

--------------------


Regards,

David Marten
Go to the top of the page
 
GroverParkGeorge
post Feb 5 2019, 08:41 AM
Post#3


UA Admin
Posts: 35,318
Joined: 20-June 02
From: Newcastle, WA


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.

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
youngb
post Feb 5 2019, 09:21 AM
Post#4



Posts: 579
Joined: 2-September 03
From: Galway, Ireland


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
Go to the top of the page
 
cheekybuddha
post Feb 5 2019, 09:42 AM
Post#5


UtterAccess VIP
Posts: 11,424
Joined: 6-December 03
From: Telegraph Hill


Hmm....

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

--------------------


Regards,

David Marten
Go to the top of the page
 
youngb
post Feb 6 2019, 03:50 AM
Post#6



Posts: 579
Joined: 2-September 03
From: Galway, Ireland


Hi,

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

Brian
Go to the top of the page
 
cheekybuddha
post Feb 6 2019, 04:53 AM
Post#7


UtterAccess VIP
Posts: 11,424
Joined: 6-December 03
From: Telegraph Hill


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'

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    22nd July 2019 - 12:32 AM