How do I define Database and Relation data types?

R

R. Johnson

Using Access 2002 SP-2.

I want to join a native table to a table that is imported from a query in
another DB, so I started with the sample CreateRelation code in the Help
file. The first line is

Dim dbs As Database, rel As Relation, fld As Field

I get an undefined data-type error for Database and Relation (but Field is
fine). So, I was going to try a Type statement to create them. But the Type
statement wants at least one "element" in the type, and all of the Help file
example data types' elements appear to be table-like fields. I don't know
what elements to use in defining Database and Relation, or what data-types
the elements should be (I assume Object, but I don't know).

(This is new VBA turf for me.)
 
B

Brendan Reynolds

You need to add a reference (select References from the Tools menu in the
VBA editor) to the Microsoft DAO 3.6 Object Library.

If you also have a reference to the Microsoft ActiveX Object Library, be
careful to disambiguate when declaring variables of types that exist in both
libraries, for example Dim fld As DAO.Field or Dim fld As ADODB.Field. If
you don't disambiguate, VBA will default to using whichever library appears
first in the list of references.
 

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