views:

343

answers:

3

I inherited an access 2003 ADP file which uses sql 2000 as it's data source. This is my first access maintenance project and not thinking about the issues involved simply opened it in access 2007 on my dev machine. It of course worked and I proceeded to do the work requested.

I have completed the work and presented the file to the client, which he opens in access 2003 and proceeds to receive several errors, all related to variables not being declared. It is at this point I realize that none of the code files have Option Explicit set. I look at the project in access 2007 again - no errors. The behaviour is as if access 2007 is respecting the Lack of Option Explicit and working as expected, but access 2003 "thinks" Option Explicit is set, even though it never appears in any code files.

I realize I could just re-do the work using only access 2003, but that would be more time-consuming than I'd like. Can anyone offer advice or a solution?

Thank you.

A: 

Weird problem - I can't see how Access 2003 would check for explicit varible declarations without any Option Explicit. Something else must be going on.

Can you reproduce the behaviour on your machine using Access 2003?

How about you actually declare your variables? You should have Option Explicit set regardless.

UPDATE:

Since the goal is to try and get the Access 2003 mdb (saved from 2007) working. I would try one more thing.

Using Access 2003 open the mdb with the /decompile switch

  • Make a backup of your mdb
  • Open your mdb (hold the SHIFT key down to stop any code from running) via a short cut: msaccess.exe database.mdb /decompile
  • Open a module and compile your app
  • Save and close Access
  • Open again (SHIFT again) without decompile
  • Compact and repair database
  • close Access
DJ
dontera
Apparently this project never compiled to begin with - neither 2003 or 2007 will. It throws on all lines with a Me.{ComboBox}.ListCount reference in it. Being new to Access development I do not understand how this project even work w/out being able to compile?
dontera
Access will run uncompiled projects but it not a good practive as you found out. In Access development ALWAYS use Option Explicit and ALWAYS compile your project. Good luck fixing this mess.
DJ
Thank you for your assistance, sir. You have, unfortunately, answered my question.
dontera
A: 

This isn't going to help you much, but I learned very quickly when one of my clients switched over to Office 2007 that I should NEVER work on a 2003 db in 2007 and then try to run it in 2003. Developing in 2007 then converting to 2003 doesn't work either. Developing in 2003 and then running the 2003 db (without conversion) in 2007 works pretty well. Most of the time.

A possible answer for the second part of your question: 1. Convert your 2007 db to 2003 format. 2. Open a new empty db in 2003 3. Import all objects from the converted 2003 db. Recompile, and try it on your client's machine.

dsteele
As experience is showing - don't cross the streams.
dontera
I should also add that I have had a long correspondence with another Access developer whose company switched to Office 2007. He spent two months unsuccessfully trying to get his 2003 dbs to work in 2007, and is now experimenting with using the 2003 runtime.
dsteele
FWIW, I haven't worked much with A2007, but I haven't had any problems getting A2000/A2003 MDBs to run in A2007 (even in the runtime). But I never write more than a few lines of code without compiling, so I always know my apps compile. And OPTION EXPLICIT should always be ON, of course.
David-W-Fenton
A: 

I had this problem too. I am 2 years into developing an Access 2003 front end that connects to an SQL backend. I stupidly started to use Access 2007 thinking all i had to do was save in 2003 format and all would be well.

Not so. All my users still using 2003 reported problems.

The problem was easy to solve in the end. I didn't actually use any 2007 features and so all that was changed was the library references. I had 2 missing references to the Word and Excel 12.0 libraries, which were automatically included just by opening the database in 2007. Thanks for nothing Microsoft.

Took those references out and i was able to 'fix' my database without having to revert back to an earlier version, losing 2 days work.

I hope this helps someone.

Andy G
Most experienced Access developers don't add any references beyond the three default references required by Access, i.e., VBA, Access and DAO. Late binding is used for any external apps, which means your app will work with whatever version of Word or Excel is installed on any particular workstation. The native Access references will be fixed up at runtime to point to the installed version (unless you've got both versions installed on one machine and haven't allowed the target version to fully re-register itself after running the other version).
David-W-Fenton