My team were working with access 2000, where we have our MDB project. This application(ERP) could open around 20 access forms. After we decide migrate our entire system to Acces
After months of frustration I have found a cause and a solution for this in both Access 2010 and Access 2013. Having Skype loaded in the background when running the program was causing the "System resource exceeded error" during both large queries and compact and repair.
If you still have problems run in windows xp compatibility mode
Building off of the VM tracking code provided by Mint, I've made a sort of 'Early warning' system for my application that warns you when the VM is approaching a point where it'll start causing problems and recommend a reboot. It's slightly annoying, but until someone comes up with a better solution to 32-Bit Office running in a 64-Bit OS environment, it'll have to do.
ReturnVM: Returns the Virtual Memory usage in GB, triggers alert if it's over 1.425GB. I've found that this works for my application giving as much time between restarts while still allowing some leeway to finish work before restarting. Feel free to adjust as needed.
os_Restart: Writes a batch file that kills the active Access process, deletes the leftover laccdb file and restarts the application (provided everything's on the user's desktop). After writing the file, it executes the batch. Another function deletes this file on application start.
TempVars!tv_WinUID = Environ("USERNAME")
Function ReturnVM() As Double
Dim Mem As MEMORYSTATUS
Dim Result As Integer
Mem.dwLength = Len(Mem)
GlobalMemoryStatus Mem
ReturnVM = Format((Mem.dwTotalVirtual - Mem.dwAvailVirtual) / 1073741824, "0.000")
Debug.Print ReturnVM & " GB of VM used."
If (ReturnVM >= 1.425) Then
DoEvents
Result = MsgBox("Office Virtual Memory usage is approaching the pre-set limit." & vbCrLf & vbCrLf & "To prevent a possible crash, please click 'OK' to restart immediately." & vbCrLf & vbCrLf & "You may click 'Cancel' to finish what you're working on, but if you do, please restart the application as soon as possible.", vbOKCancel)
If (Result = vbOK) Then
os_Restart
End If
End If
End Function
Public Function os_Restart()
Dim fso As Object
Dim oFile As Object
Dim BatchContents As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.CreateTextFile("C:\Users\" & TempVars!tv_WinUID & "\Desktop\RestartAccess.bat")
BatchContents = "@echo Restarting Application..." & vbCrLf & _
"@echo off" & vbCrLf & _
"taskkill /f /im MSACCESS.EXE" & vbCrLf & _
"ping -n 6 127.0.0.1 > nul" & vbCrLf & _
"del " & Chr(34) & "C:\Users\" & TempVars!tv_WinUID & "\Desktop\Application.laccdb" & Chr(34) & vbCrLf & _
"start " & Chr(34) & Chr(34) & " " & Chr(34) & "C:\Users\" & TempVars!tv_WinUID & "\Desktop\Application.accdb" & Chr(34)
DoEvents
'Debug.Print BatchContents
oFile.WriteLine BatchContents
oFile.Close
Set fso = Nothing
Set oFile = Nothing
Call Shell("C:\users\" & TempVars!tv_WinUID & "\Desktop\RestartAccess.bat")
End Function
The issue is caused by 32 bit Access exceeding the 32 bit windows Virtual Memory limit of 2GB per app. I don't know why this issue does not crop up on Windows XP (didn't have time to test it).
You can track VM usage either through Performance Monitor or through code in the access app. You will see that as forms open the VM usage creeps up until access balks.
The solution is to switch to Access 64 bit on windows 64bit. Keep in mind that if you have external dll calls they need to be rewritten for 64 bit. Also ActiveX controls need to be 64 bit.
Code to track VM
Declare PtrSafe Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Public Type MEMORYSTATUS
dwLength As Long
dwMemoryLoad As Long
dwTotalPhys As Long
dwAvailPhys As Long
dwTotalPageFile As Long
dwAvailPageFile As Long
dwTotalVirtual As Long
dwAvailVirtual As Long
End Type
Function ReturnVirtualMemory() As Long
Dim Mem as MEMORYSTATUS
Mem.dwLength = Len(Mem)
GlobalMemoryStatus Mem
ReturnVirtualMemory = Mem.dwTotalVirtual - Mem.dwAvailVirtual
End Function
This may help as did for me: Activate system managed paging on all your drives. For this,
Example Screenshot