Lộc Nguyễn
Lộc Nguyễn

Reputation: 1

The database cannot be opened because the VBA project contained in it cannot be read when open .accdb

https://i.sstatic.net/57JO73HO.png

Message error I received a request from a customer who wanted to run the Access system on both 32bit and 64bit environments. Example code:

' Windows  API‚

#If Win64 Then ' 64Bit

Declare PtrSafe Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal Flags As LongPtr, ByVal ProcessID As LongPtr) As LongPtr

Declare PtrSafe Function Process32First Lib "kernel32" (ByVal hSnapshot As LongPtr, ByRef ProcessEntry As PROCESSENTRY32) As LongPtr
    
Declare PtrSafe Function Process32Next Lib "kernel32" (ByVal hSnap As LongPtr, ByRef ProcessEntry As PROCESSENTRY32) As LongPtr
    
Declare PtrSafe Function CloseHandle Lib "kernel32.dll" (ByVal hObject As LongPtr) As LongPtr

#Else

Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal Flags As Long, ByVal ProcessID As Long) As Long


Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, ByRef ProcessEntry As PROCESSENTRY32) As Long
    
Declare Function Process32Next Lib "kernel32" (ByVal hSnap As Long, ByRef ProcessEntry As PROCESSENTRY32) As Long
    
Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As LongPtr) As Long

#End If

I got an error when converting accdb file from Access 32 bit to 64 bit. I have done the conversion rules and it ran successfully on Access 64bit. But the problem appeared when I used the same file to open it again on Access 32bit, it showed VBA error.

What's more strange is that I have a machine running a 32bit environment and it can still open the file normally (only that one machine).

I have experimented with Access's option settings but all to no avail.

Reproduction:

  1. Open .accdb on Access32bit
  2. Edit VBA for 64 bit compatibility
  3. Test ( Access 32bit => OK; Access 64bit => OK ; Back to Access 32bit => False)

*When I open the file (the error occurs when I open it on 64bit Access environment)

the references are no longer fully added. But the Visual Basic For Application reference is unchanged " C:\Program Files (x86)\Microsoft Office\root\vfs\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA7.1 ".

=> I guess this missing reference is due to the VBA files not being readable leading to the reference declarations not being passed

File is not corrupted

enter image description here

File corrupted (after running on Access 64bit)

enter image description here

Upvotes: 0

Views: 185

Answers (0)

Related Questions