We help IT Professionals succeed at work.

Access 2010 ACCDE file not running VBA code, ACCDB runs VBA code fine

Hi Experts

Problem statement: Access 2010 ACCDE file not running VBA code, ACCDB runs VBA code fine

Environment

Development
Windows 7 64bit
Access 2010 Pro 32bit

Deployment
Windows 8.1 64bit
Access 2010 runtime 32bit

Original Application/Database history
Access 2003 Front End, MDB for development, MDE in deployment
Access 2003 Back End, MDB in both development and deployment

Converted FE to Access 2010 by Compact and Repair, Compile, Compact and Repair, Save As ACCDB
BE left in Access 2003 MDB

The ACCDB file opens fine (opening screen is login with username and password text boxes and Login command button) The Login command button runs code as expected. FE application picks up data from BE database as expected.

Access 2010 Deployment
To produce ACCDE file suitable for deployment ACCDB file was Compact and Repaired, Save & Publish - Make ACCDE file. Produced ACCDE file with no errors.

On deployment machine application starts ok and displays Login form. However Login Command button does NOT appear to run any code. No error message given just doesn't function.

Back on development machine same thing ACCDE file does not appear to run VBA code, no error message. However by checking VB on development machine I can see only three references whereas in the ACCDB file i have four references. The missing reference is "Microsoft office 14.0 Access database engine Object Library".

If I drop that reference in the ACCDB file then clicking the login button immediately gives an "Compile error: user-defined type not defined" against a "Public dbs As Database" statement.

So my questions are: -

1. Is the missing reference my problem? (I think so).
2. Why would the reference by dropped during the Save As ACCDE function?
3. How can I get Access to keep this reference in rather than dropping it?

Best regards,

Alan
Comment
Watch Question

Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Is the ACCDE in a trusted location?

Author

Commented:
Hi Dale,

Thanks for your speedy reply.

Whoops meant to say that. Yes on both Development and Deployment the FE is in a trusted location. I used AddPath2010 to add the directory location to Trusted Locations on the Deployment machine as that is only running Access 2010 runtime.

Best regards,

Alan
Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
try declaring your database on that line (and everywhere else that you refer to either Database or Recordset) as DAO.

DIM db as DAO.Database
Dim rs as DAO.Recordset

Ever since A2000, you should actually explicitly declare the type of database or recordset object, and if you are using an Access BE, it should generally be DAO.

Author

Commented:
Hi Dale,

Once again many thanks for the response.

I have modified all the VB code to use explicit DAO references as suggested and resolved any issues on recompilation. If I now produce a new ACCDE file from the ACCDB files, then the VBA code works as expected.

So it looks like the problem was the compiler not handling the implicit reference to the DAO library correctly when making the ACCDE file.

Many thanks for your support.

Best regards,

Alan

Author

Commented:
Excellent responses in both time and how quickly he got to the root of the problem.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Glad to help, Alan.