OpenTable restricted/unsupported?

E

Ennex

Okay, Dan Artuso informed me that Dynaset is obsolete, so I've removed it
from my code. Also, an MS Web page tells me that the Table object is found in
the "ADO Ext. for DDL and Security" reference, so I've selected that. So my
errors on Dynaset and Table objects have gone away. Thank you.

Now attempting to compile gives:
"Compile Error:
Function or interface marked as restricted,
or the function uses an Automation type
not supported in Visual Basic",
highlighting ".OpenTable" in the statement
"Set AffilsTable = EnnexDB.OpenTable("Affiliations")"

EnnexDB is declared at the top of the module by:
"Dim EnnexDB As Database"
and is defined in the function by:
"Set EnnexDB = CurrentDb"

Can you tell me what's wrong with my use of the OpenTable property here? It
used to work in Access 2000.

Thank you for your help.

(Using Access 2003 under Win XP Pro on a Dell Inspiron 600m.)

Regards,
Marshall Burns
www.Ennex.com
 
D

Dirk Goldgar

Ennex said:
Okay, Dan Artuso informed me that Dynaset is obsolete, so I've
removed it from my code. Also, an MS Web page tells me that the Table
object is found in the "ADO Ext. for DDL and Security" reference, so
I've selected that. So my errors on Dynaset and Table objects have
gone away. Thank you.

Now attempting to compile gives:
"Compile Error:
Function or interface marked as restricted,
or the function uses an Automation type
not supported in Visual Basic",
highlighting ".OpenTable" in the statement
"Set AffilsTable = EnnexDB.OpenTable("Affiliations")"

EnnexDB is declared at the top of the module by:
"Dim EnnexDB As Database"
and is defined in the function by:
"Set EnnexDB = CurrentDb"

Can you tell me what's wrong with my use of the OpenTable property
here? It used to work in Access 2000.

Thank you for your help.

(Using Access 2003 under Win XP Pro on a Dell Inspiron 600m.)

Regards,
Marshall Burns
www.Ennex.com

If it worked in Access 2000, presumably it was because you had a
reference set to the DAO 2.5/3.5 Compatibility Library. That code has
been deprecated since Access 95. To make your code work, you must do
one of two things: (a) change the code to use DAO 3.6 constructs, or
(b) reinstate the reference to the compatibility library. In either
case, you do not want the reference to ADOX (that is, "ADO Ext. for DDL
and Security" ).

In DAO 3.5 and later, there is no Table object -- it's just another type
of recordset. With a reference set to DAO 3.6, as is normal for Access
2003, your code would be

Dim EnnexDB As DAO.Database
Dim AffilsTable As DAO.Recordset

Set EnnexDB = CurrentDb
Set AffilsTable = EnnexDB.OpenRecordset("Affiliations")
 
G

George Nicholson

Can you tell me what's wrong with my use of the OpenTable property here?
It
used to work in Access 2000.
I very seriously doubt that it worked in Access 2000. DAO Database does not
have an OpenTable property or event (and ADO doesn't have a Database
object). Neither of these object models have changed that much (if at all)
between 2000 and 2003.

DoCmd has an OpenTable method, but it doesn't set an object. Just opens a
table.

Maybe you are thinking CurrentDB.OpenRecordset("mytablename") or
CurrentDB.TableDefs("Affiliations"). Hard to say since you don't provide a
clue as to what you are trying to do.
Also, an MS Web page tells me that the Table object is found in
the "ADO Ext. for DDL and Security" reference, so I've selected that.

Yeah, but I seriously doubt that it's the kind of table you are looking for.
Uncheck this reference. Make sure "Microsoft DAO x.x" is checked.

Dim EnnexDB As DAO.Database
Dim AffilsTable as DAO.Recordset

Set EnnexDB = CurrentDB
Set AffilsTable = EnnexDB.OpenRecordset("Affiliations")"

?or, maybe?
Dim AffilsTable as DAO.TableDef

Set AffilsTable = EnnexDB.TableDefs("Affiliations")"


HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top