Acc2003 Code will not compile

  • Thread starter Thread starter OceansideDJ
  • Start date Start date
O

OceansideDJ

My code ran in Access 2000. Now in Access 2003, on >>Debug>>Compile, I get:
Compile error: Method or data member not found.

The highlighted code is the ".LastModified" in:
With rsResult
.AddNew
!PeriodNo = iPeriodAssignment
!PeriodTitle = sPeriodTitle
.Update
.Bookmark = .LastModified


Under >Tools>References I have checked:
Visual Basic for Applications
Microsoft Access 11.0 Object Library
Microsoft ActiveX Data Object Library
OLE Automation


If I add Microsoft ActiveX Data Objects Library 2.7 to References, I get:
"Ambiguous name detected: UpdateLogTable"

Changing the order of the references toggles between the two error messages.

Help much appreciated.

Mike
 
LastModified is a property of a DAO recordset, not an ADO recordset which,
based on the References you currently have selected, is what Access assumes
you mean. Both ADO and DAO object libraries have Recordsets, but they do not
have the same properties & methods.

I don't use ADO a lot, so I don't know if there is an ADO equivalent to
LastModified. On the other hand, if you want to use DAO (and if you are
using the recordset of a form, you *have* to use DAO) then:

1) You need to add a reference to the "Microsoft DAO x.x Object Library"

2) Once you do that, you will also probably need to specify that rsResult is
a DAO recordset to ensure that Access initializes the object correctly:
Replace: Dim rsResult as Recordset
with: Dim rsResult as DAO.Recordset
 
George,
Thanks. I got it to compile.

I added Microsoft ActiveX Data Object 2.7 Library, still not compiling.

Changed .recordset to DAO.Recordset. No good.

Tried Duane's boilerplate delete and recheck. Nope.

I did reinstall/repair Acc2003, no improvement.

I tried a new module in a new database, and that compiled.
So, I created a new database and imported all my old objects. Works!

I do not know if it was a combination of the steps, or just that last ditch
effort, but I am satisfied.

Thanks again for the tip. I will specify the DAO as needed.

Mike
 
I added Microsoft ActiveX Data Object 2.7 Library, still not compiling.

This is *NOT* the the same as Microsoft DAO x.x Object Library, so I am not
surprised it still wouldn't compile. (ActiveX DataObject = ADO and you
needed DAO. 2 different animals.)

I can only assume that your new database somehow started with a DAO
reference included.
 
George,
Sorry, was a typo. I did include Microsoft DAO 3.6 Library along the way.

Tried to compile in another Acc2000 database for first time in Acc2003, and no
luck until I imported all the old objects into a new database. Looks like I
have the references correct now, but they are not effective in the old
database.

Thanks for the help.

Mike



Subject: Re: Acc2003 Code will not compile
From: "George Nicholson" (e-mail address removed)
Date: 8/17/04 1:39 PM Pacific Standard Time
Message-id: said:
I added Microsoft ActiveX Data Object 2.7 Library, still not compiling.

This is *NOT* the the same as Microsoft DAO x.x Object Library, so I am not
surprised it still wouldn't compile. (ActiveX DataObject = ADO and you
needed DAO. 2 different animals.)

I can only assume that your new database somehow started with a DAO
reference included.
 
I'm not sure I followed that exactly, but if it helps at all, Access up to
and including Access 97 included a DAO reference by default in new MDBs.
Access 2000 and Access 2002 don't include that reference by default. Access
2003 includes it again. So if you have code that requires a DAO reference,
and you import that code into a new MDB created using Access 2000 or Access
2002, you'll need to add the DAO reference yourself. But if the MDB was
created using Access 2003, the reference will be included by default.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Brendan:
Thanks for the info. I didn't realize that 2003 defaults included DAO
refs once again.

Suddenly the world makes sense again. :-)
 
Back
Top