FMS Home FMS Software Development Team Blog FMS Facebook Page FMS Twitter
Jump: Search:

Microsoft Access Developer Center

Table Design

Query Design

Form Design

Form Tips and Mistakes

Form Navigation Caption

Using a RecordsetClone

Synchronize Two Subforms

Multiple OpenArgs Values

Late Bind Tab Subforms

Subform Reference to Control Rather than Field

Tab Page Reference

Shortcut Keys


Combo Box Top Tips

Properties and Validation

Select First Item

Cascading Combo Boxes

Zip, City, State AutoFill

Report Design

Suppressing Page Headers and Footers on the First Page of Your Report

Add the NoData Event

Annual Monthly Crosstab Columns

Design Environment

Adding Buttons to the Quick Access Toolbar

Collapsing the Office Ribbon for more space

VBA Programming

Using Nz() to Handle Nulls

Avoiding Exits in the Body of a Procedure

Debugging Keys

Setting Module Options

Math Rounding Issues

Rename a File or Folder

Source Code Library

Microsoft Access Module VBA Library

Royalty Free VBA Modules

VBA Error Handling

Error Handling and Debugging Techniques

Error Number and Description Reference

Basic Error Handling

Pinpointing the Error Line

Performance Tips

Linked Database

Subdatasheet Name

Visual Source Safe

Deployment

Runtime Downloads

Simulating Runtime

Prevent Close Box

Disable Design Changes

Broken References

Missing Package & Deployment Wizard

Terminal Services and RemoteApp Deployment

Avoid Program Files

Microsoft Access Front-End Deployment

System Admin

Disaster Recovery Plan

Compact Database

Compact on Close

Database Corruption

Class Not Registered Run-time Error -2147221164

Inconsistent Compile Error

Decompile Database

Bad DLL Calling Convention

Error 3045: Could Not Use

Converting ACCDB to MDB

Cloud and Azure

Cloud Implications

MS Access and SQL Azure

Deploying MS Access Linked to SQL Azure

Visual Studio LightSwitch

LightSwitch Introduction

Comparison Matrix

Additional Resources

Microsoft Access Help

MS Access Developer Programming

More Microsoft Access Tips

Technical Papers

Microsoft Access Tools

Connect with Us

Email NewsletterEmail Newsletter

FMS Development Team BlogDeveloper Team Blog

Facebook PageFacebook

Twitter with FMSTwitter

FMS Support Site Support Forum

 

 

Decompile Your Microsoft Access Database to Fix the Bad DLL Calling Convention Error

Provided by Luke Chung, FMS President

Error Message and Behavior that Make No Sense

Bad DLL Calling Convention Error

Have you seen Error 49, Bad DLL calling convention, when running what appears to be your perfectly, well written code?

When this error occurs, it's usually after one of your procedures finishes and returns to its calling procedure. However, the message makes no sense because you haven't called a DLL. Debugging and stepping through your code drives you crazy because everything is working fine, yet the error keeps popping up.

It's driving you crazy and enough for you to throw away Access! What's going on?

Queries with VBA Functions Suddenly Fail

Similarly, do your queries that have VBA code (such as Left, Mid, or UCase) start failing? How can something so simple all of a sudden stop working?

Compact and Repair doesn't help

This can all be very confusing because it makes no sense. Everything looks fine. And Compact and Repair does not help.

The initial assumption is that the database is corrupt, which is partially true. People then resort to creating a new database and importing their objects into it which is time consuming and a pain. It solves the problem, but there's a much easier way.

Possible Solutions

Fortunately, there are a few options that can resolve this problem.

Are any Library References Broken?

The first thing to check is whether the library references for your module code are valid. From the VBA IDE, go under Tools, References to see the list of referenced libraries and make sure none of the checked items say "Missing" in front of them. If so, fix that and your problem should go away. Assuming that's not the cause of the problem....

The Problem Lies with the Compile State of VBA

Unfortunately, over time, the part of your Microsoft Access database that stores VBA module code can become bloated, and in some cases, trigger strange errors such as Bad DLL calling convention.

As you compile and run code, VBA leaves behind old versions of the code that are no longer valid, but it is not always removed from the database. Database Compact and Repair only addresses the Jet tables in your database, and not the code. That's why it has no impact when this error arises.

The Access /decompile command

Fortunately, Microsoft Access has a solution with the /decompile command line option.

When Access is started with this and you open your database, it discards all the old compilations, and leaves just your VBA source code. You'll need to compile again to get the compiled state. After compacting, your database may be significantly smaller.

To decompile your database, follow these steps

  1. From the Windows, Start, Run command line, type: msaccess.exe /decompile
    where msaccess.exe includes the complete path. For example:
    C:\Program Files\Microsoft Office\Office15\MSACCESS.EXE /decompile
  2. When Access opens, open the database you want to decompile (with trusted authority for Access 2003 or later)
  3. Open up any module. Compile it via Debug, Compile.., then File, Save.
  4. Go back to the database and Compact it
    1. For Access 2010 and 2013, Database Tools, Compact and Repair Database.
    2. For Access 2007, Office Button, Manage, Compact and Repair Database.
    3. For Access 2003, 2002, 2000, and 97: Tools, Database Utilities, Compact and Repair Database

The database size should be reduced and the strange errors related to the VBA code should be gone.

Create a Shortcut

To simplify doing this in the future (and you'll likely need this again), create a shortcut on your Windows desktop pointing to where your copy of Access is located:

C:\Program Files\Microsoft Office\Office15\MSACCESS.EXE /decompile

Then, whenever your database is acting oddly, you can easily launch the decompile version of Access to open your database and decompile it. In a few minutes, you're back up and running with a smaller database.

Good luck!

Additional Resources and Technical Papers

Microsoft Access Database Administrator Products

Schedule and Automate Database Compacts

Schedule and Automate Microsoft Access Database Compacts

Total Visual Agent manages an unlimited number of databases across your network and schedule database chores in the middle of the night. Perform compact, backups, data extracts, running macros, command lines, and other tasks. Schedule events hourly, daily, weekly, monthly or just one time. Complete audit trail with email notification if anything goes wrong. Free Demo

Monitor Your Database in Real-Time

See who's currently in your Microsoft Access database and prevent corruption

Total Access Admin lets you monitor Access databases in real-time to see who's currently in it and when they leave. It flags users who disconnect in a suspect manner which may indicate a source of database corruption. It can also perform tasks after everyone has exited such as compact. Free Demo

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright FMS, Inc., Vienna, Virginia
Celebrating our 27th Year of Software Excellence