VBA Compile error when converting to Access 2007

N

Nigel D

I have converted a database from Access 2003 to 2007, but the VBA project
will not compile/run. The problem seems to be with the DAO, but when I go
into Tools References and add the MS DAO 3.6 object library back in I get an
error saying 'Name conflicts with existing module, project, or object
library'. The code it falls over on is:

Dim MyIndex As Index
Set MyIndex = MyTable.CreateIndex("PrimaryKey")
With MyIndex
.Primary = True 'falls over on this section
.Required = True
.Unique = True
End With

The message I get is 'Method or Data Member not found'. Does anyone have any
idea how to resolve this?
Many thanks
 
P

Paul Shapiro

Nigel D said:
I have converted a database from Access 2003 to 2007, but the VBA project
will not compile/run. The problem seems to be with the DAO, but when I go
into Tools References and add the MS DAO 3.6 object library back in I get
an
error saying 'Name conflicts with existing module, project, or object
library'. The code it falls over on is:

Dim MyIndex As Index
Set MyIndex = MyTable.CreateIndex("PrimaryKey")
With MyIndex
.Primary = True 'falls over on this section
.Required = True
.Unique = True
End With

The message I get is 'Method or Data Member not found'. Does anyone have
any
idea how to resolve this?

It could be an ambiguous reference. If you're using DAO, then disambiguate
the declaration as:
Dim MyIndex as DAO.Index

DAO and ADODB have similar objects, and the one you get if you don't specify
depends on the listing order of the references.

If that's not it, look at the properties of MyIndex in the debugger, after
commenting out any lines that prevent compilation.
 
D

Douglas J. Steele

Paul`s given you a good answer. I just thought I`d add in that if you're
using the new ACCDB file format in Access 2007, you must use the Microsoft
Office 12.0 Access database engine Object library, not the Microsoft DAO 3.6
Object library. You can only use the DAO object library if you've left the
database in the older MDB file format.

However, everything that's in the DAO object library is also in the Access
database engine Object library
 
G

Guest

Nigel D said:
I have converted a database from Access 2003 to 2007, but the VBA project
will not compile/run. The problem seems to be with the DAO, but when I go
into Tools References and add the MS DAO 3.6 object library back in I get
an
error saying 'Name conflicts with existing module, project, or object
library'. The code it falls over on is:

Dim MyIndex As Index
Set MyIndex = MyTable.CreateIndex("PrimaryKey")
With MyIndex
.Primary = True 'falls over on this section
.Required = True
.Unique = True
End With

The message I get is 'Method or Data Member not found'. Does anyone have
any
idea how to resolve this?
Many thanks
 
J

joelgeraldine

k:!jbb

Douglas J. Steele said:
Paul`s given you a good answer. I just thought I`d add in that if you're
using the new ACCDB file format in Access 2007, you must use the Microsoft
Office 12.0 Access database engine Object library, not the Microsoft DAO
3.6 Object library. You can only use the DAO object library if you've left
the database in the older MDB file format.

However, everything that's in the DAO object library is also in the Access
database engine Object library
 

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