VBA code or API that informs me if a Microsoft Access 2003 form has been minimized

What VBA function may I use after giving it the form name and tell me true or false if its minimized - if so then restore back to size?

Public Function Minimize_Form(sForm As String)
  If Min(sForm) = True Then
     'don't maximize form just restore it to its normal state
    Forms!----sForm....
  End If
End Sub
LVL 1
stephenlecomptejrAsked:
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.

CarlWarnerCommented:
I am not an Access developer.  

In VFP, there is a WindowState property which can be evaluated to determine what state a form is in.  The return values are as follows:

[Object.]WindowState[ = nState]

0
 Normal
 
1
 Minimized (minimized to an icon). If the main Visual FoxPro window is minimized when you exit Visual FoxPro, the main Visual FoxPro window will not display before exiting. If your application displays a dialog before exiting, be sure to set _SCREEN.WindowState to 0 before displaying the dialog.
 
2
 Maximized (enlarged to fill the screen)
 
WindowState Property (Visual FoxPro)
http://msdn2.microsoft.com/en-us/library/7stcectz(VS.80).aspx

In VBA, I saw the following blurb:

For information about how to affect module windows see the WindowState property topic.
0
stephenlecomptejrAuthor Commented:
Basically I have a main menu without minimize, maximize, and close button and it resides directly over the Database Window.  

Sometimes people access the Database Window - when that occurs the main menu screen is shown behind the smaller sized database window.  I have a toolbar that when they click on it allows them to go back to the main menu.  The problem is that the macro code below only opens the main menu form if its closed.  If it is already opened in this situation - then nothing happens because the main menu is opened it is just behind the Database Window.  Basically I need to rewrite the following code to allow the user to go back to the main menu no matter what its state.  Perhaps I could set focus to the main menu form in this situation?

Public Sub MainMenu()
On Error GoTo Err_MainMenu

  'If IsOpen("frmMainMenu") = True Then DoCmd.Close acForm, "frmMainMenu"
  If IsOpen("frmMainMenu") = False Then DoCmd.OpenForm "frmMainMenu"
 
  Forms!frmMainMenu!tbMain.Value = 0
  Call Erase_Misc
  Forms!frmMainMenu!cmdRefresh.SetFocus
  DoEvents
 
Exit_MainMenu:
    Exit Sub
   
Err_MainMenu:
  If Err = 2102 Then
      MsgBox "This toolbar does not work for this particular program!"
      GoTo Exit_MainMenu
    End If
   
  Call Error_Action(Err, Err.description, "modGlobal @ MainMenu", Erl())
  Resume Exit_MainMenu
End Sub  
0
jefftwilleyCommented:
Look into the restore command in Access. You can also use MoveSize if you want to reposition your form to a particular place in the screen.
J
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Jeffrey CoachmanMIS LiasonCommented:
stephenlecomptejr,

So basically you want to bring your MainMenu code to bring your "frmMainMenu" back to the front? (Have the Focus)?

Try this:

Public Sub MainMenu()
On Error GoTo Err_MainMenu

  'If IsOpen("frmMainMenu") = True Then DoCmd.Close acForm, "frmMainMenu"
  If IsOpen("frmMainMenu") = False Then DoCmd.OpenForm "frmMainMenu"

  Forms!frmMainMenu.SetFocus  '<---Try this
 
  Forms!frmMainMenu!tbMain.Value = 0
  Call Erase_Misc
  Forms!frmMainMenu!cmdRefresh.SetFocus
  DoEvents
 
Exit_MainMenu:
    Exit Sub
   
Err_MainMenu:
  If Err = 2102 Then
      MsgBox "This toolbar does not work for this particular program!"
      GoTo Exit_MainMenu
    End If
   
  Call Error_Action(Err, Err.description, "modGlobal @ MainMenu", Erl())
  Resume Exit_MainMenu
End Sub  

This will bring the MainMenu back to the front, you may have to move it around in your code to get it to work correctly.

If not, then we will have to go back and dig a little more deeply into your code.

Let us know

JeffCoachman
0

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
stephenlecomptejrAuthor Commented:
As the Guiness beer commercial would say 'Brilliant'
0
Jeffrey CoachmanMIS LiasonCommented:
;-)
0
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
Microsoft Access

From novice to tech pro — start learning today.