2

I've got a project in Access 2010 that runs without issues. That is, until I add a breakpoint and I try to debug code. As soon as it reaches the first breakpoint, the VBA project opens up and about 1 second later Access crashes and restarts. I can add a Debug.Print and all works fine. I just can't step through code.

Repair and compact did not work, nor to create a new project and import everything.

Looking at the event viewer I get:

Faulting application name: MSACCESS.EXE, version: 14.0.4750.1000, time stamp: 0x4b8bae0f
Faulting module name: ntdll.dll, version: 6.2.9200.16579, time stamp: 0x51637f77
Exception code: 0xc0150010
Fault offset: 0x00000000001041c0
Faulting process id: 0x2ef4
Faulting application start time: 0x01cf180a44c35b8a
Faulting application path: C:\Program Files\Microsoft Office 2010\Office14\MSACCESS.EXE

I can't unregister and reregister the DLL (entry point not found). I've tried everything on http://pcsupport.about.com/od/fixtheproblem/a/ntdlldll.htm short of reisntalling Windows and still nothing. Running Access in Safe mode does help, but does not fix it permanently.

Any other ideas?

UPDATE: I now have a new laptop and upgraded to Access 365. And it still happens. But only on one specific project. Other projects work fine.

Cameron Castillo
  • 2,712
  • 10
  • 47
  • 77
  • Have you backed-up, compacted and repaired and decompiled http://www.granite.ab.ca/access/decompile.htm? After that, you can copy everything into a fresh db, if necessary. Have you also tried a repair on MS Access? Do other projects work properly? – Fionnuala Jan 23 '14 at 08:48
  • Is it possible that you have add-ins? – Fionnuala Jan 23 '14 at 08:54
  • Yes, I do have add-ins, but they are working on other accdb projects. So yes, there are others that are working. I have compacted and repaired. I've also tried copying everything over in fresh db - no success. Will run decompile now. How do you repair MS Access? – Cameron Castillo Jan 23 '14 at 09:56
  • You usually decompile and compact and repair before copying. To repair http://office.microsoft.com/en-ie/project-help/repair-office-programs-HA010357402.aspx – Fionnuala Jan 23 '14 at 10:01
  • Oh, that repair. Just did it. No success. Also interesting is that if I call a function from the Debug window then Access does not crash. Calling the same function from an event is okay if there's no breakpoint. Adding a breakpoint (when calling from event) and it crash. Boom. – Cameron Castillo Jan 23 '14 at 12:42
  • I am lost. There are various posts in Google on ntdll.dll errors, I do not know if they will help http://pcsupport.about.com/od/fixtheproblem/a/ntdlldll.htm – Fionnuala Jan 23 '14 at 15:31
  • I'm lost as well. It seems like that is the same website in my original post. Work through all of that as well. I also replaced the dll with a ntdll-fix program, but the same. I guess that's the symptom of something else. – Cameron Castillo Jan 24 '14 at 06:11
  • You could try checking references and removing any that are not standard for MS Access. That is, move to late binding for any odd references. – Fionnuala Jan 24 '14 at 09:34
  • Try creating a new empty database and import all the objects from one of the other ones. You'll have to add any references as well. – HK1 Jan 24 '14 at 14:02
  • That was done a couple of times. It will work for a couple of minutes and then start failing again. – Cameron Castillo Jan 27 '14 at 06:30
  • The event viewer report indicates an error in MSACCESS.EXE. Looks like a bug in this version of Access 2010. Support ended on October 13, 2020, so you're more or less doomed IMHO. However if you have the same problem with Access 365, you should report to Microsoft. – Simon Mourier Jan 19 '22 at 09:57
  • Please see latest edit on the post. Error still occurs even in Access 365. – Cameron Castillo Jan 19 '22 at 13:07
  • Does your VBA project contain any code that does hooking (like mouse wheel scroll) or code that subclasses a window? Or Win API timers? – Cristian Buse Jan 19 '22 at 13:26
  • Valid question. But no, nothing of that sorts. But I guess it's worth while to start importing a small amount of forms and code first into a new project and take it bit by bit until it crashes. Makes sense that there is 1 specific area that causes this. – Cameron Castillo Jan 19 '22 at 18:46
  • 1
    Indeed, you need to isolate by dividing your code into smaller and smaller chunks until you find the issue. Please note that I do not get notified when you leave a message unless you prefix with @CristianBuse. I do not need to do that because it's your question and you get notified automatically. Are you working on 64 bits Office or 32? There are a few known 64 bit bugs like [this one](https://stackoverflow.com/questions/63848617/bug-with-for-each-enumeration-on-x64-custom-classes) – Cristian Buse Jan 20 '22 at 11:44
  • 1
    You could try one of the solutions [here](https://stackoverflow.com/questions/187506/how-do-you-use-version-control-with-access-development) to export and rebuild all modules from text files. This may (or may not) be able to remove more "binary corruption" than importing all objects into a new db. – Andre Jan 25 '22 at 14:55

2 Answers2

0

Seems this is not the first time this type of error happens https://learn.microsoft.com/en-us/answers/questions/269052/vba-access-stop-command.html

The above link is very detailed (in terms of text + screenshots) and may be similar to what you experience.

Anyhow... please try to open your access software using the run as administrator option (right click access icon and pick this option). There is a chance that vba is trying to use elevated permissions and without it - it results in a spectacular crash

ymz
  • 6,602
  • 1
  • 20
  • 39
  • Thanks. Running as Admin does not solve it. And yes, the link you provided does seem to be the same as mine. Pity there's no solution there (at the time of writing). – Cameron Castillo Jan 25 '22 at 11:50
  • well.. the author managed to "solve" this by using an older version of the product (if I understood correctly) - I refer to the last post on this thread, last sentence written. But yes - not mush of a solution – ymz Jan 25 '22 at 11:57
  • I've tried both 2010 and 365. – Cameron Castillo Jan 25 '22 at 18:48
  • it will be so wonderful if you'll be able to solve this and post here a solid solution - `ms access` was my first `db` when I've started my way.. around 20 years ago... and it had it's own set of problems. It amaze me that it giving such a hard time to others as well... unbelieveable – ymz Jan 26 '22 at 08:41
0

I got this error and discovered it was because of not declaring a variable as the correct type when using the GetUserName function, declared from the advapi32.dll library. I had to change "Dim buffer As String" to "Dim buffer As String * 256" before I could call "GetUserName(buffer, Size)". This is the code:

#If VBA7 Then
Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" _
  Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#Else
Private Declare Function GetUserName Lib "advapi32.dll" _
  Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#End If

Function getNetworkName() As String
    Dim ret As Long, Size As Long
    Dim buffer As String * 256
       
    Size = 256
    ret = GetUserName(buffer, Size)
    If ret <> 0 Then
        getNetworkName = Mid(buffer, 1, InStr(1, buffer, vbNullChar) - 1)
    Else
        getNetworkName = "API ERROR"
    End If
End Function

I don't know if your issues would be the exact same thing, but maybe it's due to a data type issue like this.