Need help with code

EternalMyrtle

I'm still alive
Local time
Yesterday, 16:54
Joined
May 10, 2013
Messages
533
Hello,

I have been trying to write some code to be used when my forms close. The code checks if other forms are loaded and, if not, opens the switchboard. My problem is that the switchboard is opening all the time. I am hoping it will be an easy fix for someone with more experience.

Here is the code:

Code:
Public Function OpenMainMenu()
Dim frm As AccessObject

With CurrentData
    
With CurrentProject
   ' "Forms"
   
   For Each frm In .AllForms
   If frm.Name <> Screen.ActiveForm.Name Then
       If frm.IsLoaded = True Then
       Exit Function
    Else:
       DoCmd.OpenForm "frmMainMenuBDPR"
       End If
       End If
         Next frm
  
End With
End With



End Function

Thank you!
 
Put the OpenForm after the loop, not in the Else.
 
I tried that but now nothing happens :(
 
I don't have a swtichboard just an Ordinary form which that remains all the time and once all other Forms are closed it will appear (always in a Maximised state.)

Simon
 
Simon_MT: this is a good solution without code. However, I do have one question: would keeping the main form in memory slow down other operations? I could definitely use this method but I want to make sure that performance won't be affected.

Thanks!
 
No. This is just a form and you can load multiple forms at any given time. In the pass you could use a drop-down and go to any open form, this relates back to Access 1997. In Access 2007 I have even added background images and Button images without noticing any performance issues.

Simon
 

Attachments

  • menu.jpg
    menu.jpg
    91.2 KB · Views: 63

Users who are viewing this thread

Back
Top Bottom