Fix Microsoft Access Crashing After Adding a VBA DLL Declaration
Question details
The user's application crashes after manually declaring an external DLL function in VBA.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Adding and calling external DLL functions, such as DllG.dll, within an Access VBA module.
- Observed behavior
- Microsoft Access crashes unexpectedly when executing the VBA code containing the external API declaration.
Before proceeding, ensure you have a backup of your Access database and verify that you have access to the official documentation for the external DLL you are trying to call.
Review and Correct the VBA Declare Statement
Verify that your VBA declaration exactly matches the external API's required data types, calling conventions, and parameters to prevent memory corruption and crashes.
A common cause of Access crashing when calling an external DLL is a mismatch in the API definition. External libraries like DllG.dll are not native Access system files, meaning VBA relies entirely on your manual declaration to allocate memory correctly. If parameters are incorrect, it causes an immediate fatal error.
Open your Microsoft Access database and press Alt + F11 to launch the Visual Basic for Applications (VBA) Editor.
Check the official documentation provided by the developer of the DLL (e.g., DllG.dll). Identify the exact data types required for each parameter and the expected return type.
Modify your Declare statement in the VBA module to match the required parameters. Ensure you are passing arguments ByVal or ByRef as specified by the API.
In the VBA Editor menu, go to Debug > Compile Database to check for syntax or type mismatch errors before running the code.
Ensure 32-bit and 64-bit Compatibility
Office bitness heavily impacts DLL declarations. Incorrectly mapping 32-bit declarations in a 64-bit Access environment often leads to instant application crashes.
Experience a Stable and Lightweight Office Suite with WPS Office
Tired of dealing with complex crashes and heavy system requirements in Microsoft Office? While WPS Office doesn't directly replicate Access databases, it provides a highly stable, lightweight, and free alternative for all your document, spreadsheet, and presentation needs. Enjoy seamless compatibility, powerful data handling in WPS Spreadsheets, and a familiar interface without the frustration.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the installer and follow the quick on-screen instructions to set up the lightweight suite.
- 3. Open Your Files: Launch WPS Office and directly open your existing Word, Excel, and PowerPoint files without formatting loss.

Frequently Asked Questions
Why does Microsoft Access crash immediately when executing my VBA code?
This typically occurs due to a mismatch between the expected parameters of an external DLL and what your VBA code provides, or by running a 32-bit API declaration in a 64-bit version of Access without proper adjustments.
What is DllG.dll and why is it causing an error?
DllG.dll is not a standard Microsoft Access system file. It is a third-party or custom external API library. If it causes crashes, you must review its specific documentation to ensure your VBA declaration perfectly matches its requirements.
How do I safely declare a Windows API in 64-bit Access?
In 64-bit Microsoft Access, you must include the 'PtrSafe' keyword in your 'Declare' statement and use the 'LongPtr' data type for any variables that store memory pointers or handles.




