• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

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
0
stephenlecomptejr
Asked:
stephenlecomptejr
1 Solution
 
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now