VBA Userform stops working after some time


I have a userform that i load from a control in an excel sheet.
It loads fine the first time and normally also a couple times more, but after some time, i will get the error 75(Path/File access error) "Could not find the specified object."

sub UITest is run from the control on the sheet, showing the form
sub  bGenerate_Click() is run from the form
Sub GenerateReport() is the sub that hides an unloads the form.

If I switch to the VBE after getting the error, I can show the code of the form, but i cannot show the form in the editor window

Anyone run into this before?
Sub UITest()
On Error GoTo ErrHandler:
Exit Sub
    'LogInformation Err.Number & " - " & Err.Description & " - " & Err.Source & " - " & Err.LastDllError
    LogInformation Format(Now, "yyyy-mm-dd hh:mm:ss") & ": @ UITest in Module3 " & " - " & Err.Number & " - " & Err.Description & " - " & Err.Source & " - " & Err.LastDllError
End Sub
Private Sub bGenerate_Click()
End Sub
Sub GenerateReport()
On Error GoTo ErrHandler:
    Dim m_Controller As Controller
    Set m_Controller = New Controller
    '... lines of code fetching the checkbox values from the form, ex.
    '...m_Controller.BVal = uWMain.CBAFG.Value
    Unload uWMain
    'Clean up
    Set m_Controller = Nothing
Exit Sub
    LogInformation Format(Now, "yyyy-mm-dd hh:mm:ss") & ": @ GenerateReport in Module3 & " - " & Err.Number & " - " & Err.Description & " - " & Err.Source & " - " & Err.LastDllError"
End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It might be a problem in the form's code. I suggest that you remove the error handling, so that it breaks immediately on the failing line.
The only thing that I can think of is to assign your form to an object and then destroy the object at the end.  This should stop it getting stored in the memory

dim objuWMain as object

set objuWMain as new uWMain

'then load it up / show it ext and at the end just throw it away

set objuWMain = Nothing

Rory ArchibaldCommented:
I would also run Code Cleaner on your workbook if you haven't already. Available here: http://www.appspro.com/Utilities/CodeCleaner.htm
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

mortenbkAuthor Commented:
The error is from the command

Same error

It feels like the garbage collector removes the form-object

Err.Number: 75
Err.Description: Could not find the specified object.
Err.Source: Forms.Form.1
mortenbkAuthor Commented:
CodeCleaner done, same result, let it linger for 15 minutes and the object disappears
mortenbkAuthor Commented:
Guess I'll cloe this one myself...
 Never did find out what casues the crash, but if the whole shebang is run without the VBE open, it will not crash.... not that way anyways

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.