0

As the title says, I am being faced with an issue where my Access applications hangs on the line (see below). THis function is being called from somewhat of a busy form.

 End Function

I have done quite a bit of research to try and pin point the issue.

I stepped through the code watching the locals window looking for hanging objects.

I have verified that all recordsets are being dealt with appropirately (there happens to be none actually).

I have converted any sql strings in the properties dialog to saved queries (I thought this would help due to the form having quite a few controls).

I have added error handling t the function to see if there were any issues. Peculiarly enough, the error handling does alleviate the issue temporarily. After a short session of banging on the form that calls the function, eventually it'll go back to the hanging. If I open and reclose the DB this also helps. THis tells me that something is bloating/hanging in the back ground, but Im not sure what else I need to check.

Any pointers, advice or suggestions would be greatly appreciated

function

Public Function IsAdmin() As Boolean
On Error GoTo IsAdminErr

Dim errany
IsAdmin = AdminUser ' adminuser is a global variable that is set on file open
Debug.Print ;

 IsAdminCleanUp:

Exit Function

 IsAdminErr:
 If DBEngine.Errors.Count > 1 Then
    'ODBC Error
    For Each errany In DBEngine.Errors
         Debug.Print ; errany.Number
         Debug.Print ; errany.Description
    Next errany
Else  'Access Error    
    Debug.Print ; errany.Number
    Debug.Print ; errany.Description
End If
GoTo IsAdminCleanUp
End Function
Doug Coats
  • 6,255
  • 9
  • 27
  • 49
  • If this is not enough information just let me know I can add whatever. – Doug Coats Nov 07 '17 at 17:45
  • 4
    Uhm, so, what's the function returning? A 42TB variant array? – Mathieu Guindon Nov 07 '17 at 17:59
  • Please try to provide enough information for us to replicate the problem (try to replicate it yourself in a second database with the minmal required code). Currently, it's hard for me to help you with this little information. – Erik A Nov 07 '17 at 18:00
  • @Mat'sMug it returns a boolean value. The original function before I added error handling was just assigning true/false to whether or not end user was "admin" – Doug Coats Nov 07 '17 at 18:01
  • Note the things that happen when a function ends 1. a value gets returned 2. any object that's out of scope gets marked for removal (garbage collection). That last one might be the most obvious culprit in a hang, if only a boolean gets returned – Erik A Nov 07 '17 at 18:05
  • 2
    @ErikvonAsmuth except VBA isn't garbage-collected, it's ref-counted ;-) ..but yeah, could be something like it. – Mathieu Guindon Nov 07 '17 at 18:06
  • 1
    @Yowek I posted the current state of the function - the error handling is a recent addition. I guess i wasn't clear that it hangs on exit function now. Sorry if that wasnt clear. THe extra space is more of a formatting issue from my posting here. There are no extra spaces in the editor within access. – Doug Coats Nov 07 '17 at 20:47
  • Probably best to update the question so that the problem statement refers to the posted code. It's a really weird issue, so the answer could be really weird too, and therefore the more exact the question description the better the chance of solving. – YowE3K Nov 07 '17 at 21:01
  • 2
    Have you tried decompiling the DB? It can sometimes fix these oddball issues: https://stackoverflow.com/questions/3266542/how-does-one-decompile-and-recompile-a-database-application – Fink Nov 07 '17 at 21:34

1 Answers1

2

I've never seen a function stall on End Function, but your IsAdminErr subroutine isn't clearing its error state properly. This:

GoTo IsAdminCleanUp

Should be:

Resume IsAdminCleanUp

I don't expect it to fix anything though - the local error state should get cleared on exit anyway.

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235