Hide Access Window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hutch
    New Member
    • Mar 2007
    • 74

    #16
    Got it to work, Really have no idea but it works!! Thanks

    Comment

    • Denburt
      Recognized Expert Top Contributor
      • Mar 2007
      • 1356

      #17
      Your module "SetAccessWindo w"

      Should look something like this"
      Code:
      Option Compare Database
      Option Explicit
      
      Global Const SW_HIDE = 0
      Global Const SW_SHOWNORMAL = 1
      Global Const SW_SHOWMINIMIZED = 2
      Global Const SW_SHOWMAXIMIZED = 3
      Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long
      Private Declare Function apiShowWindow Lib "user32" _
      Alias "ShowWindow" (ByVal hWnd As Long, _
      ByVal nCmdShow As Long) As Long
      Function fSetAccessWindow(nCmdShow As Long)
      
      Dim loX As Long
      Dim loform As Form
      On Error Resume Next
      Set loform = Screen.ActiveForm
      
      If Err <> 0 Then
      loX = apiShowWindow(hWndAccessApp, nCmdShow)
      Err.Clear
      End If
      
      If nCmdShow = SW_SHOWMINIMIZED And loform.Modal = True Then
      MsgBox "Cannot minimize Access with " _
      & (loform.Caption + " ") _
      & "form on screen"
      ElseIf nCmdShow = SW_HIDE And loform.PopUp <> True Then
      MsgBox "Cannot hide Access with " _
      & (loform.Caption + " ") _
      & "form on screen"
      Else
      loX = apiShowWindow(hWndAccessApp, nCmdShow)
      End If
      fSetAccessWindow = (loX <> 0)
      End Function
      Function rSetAccessWindow(nCmdShow As Long, Optional myRep As Report)
      Dim loX As Long
       Dim intWindowHandle As Long
      If nCmdShow = SW_SHOWMINIMIZED And myRep.Modal = True Then
          MsgBox "Cannot minimize Access with " _
          & (myRep.Caption + " ") _
          & "report on screen"
      ElseIf nCmdShow = SW_HIDE And myRep.PopUp <> True Then
          MsgBox "Cannot hide Access with " _
          & (myRep.Caption + " ") _
          & "report on screen"
      Else
          loX = apiShowWindow(hWndAccessApp, nCmdShow)
      End If
      
      rSetAccessWindow = (loX <> 0)
          intWindowHandle = myRep.hWnd
          If Not IsZoomed(intWindowHandle) Then
              
      DoCmd.Maximize
          End If
      End Function
      
      !!!SECOND!!! you have to paste this code into every form
      
      Private Sub Form_Load()
      Call fSetAccessWindow(0)
      End Sub
      
      In each report you need to enter the following:
      
      Private Sub Report_Open(Cancel As Integer)
      Call rSetAccessWindow(0, Me)
      End sub

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #18
        Originally posted by Hutch
        loX = apiShowWindow(h WndAccessApp, nCmdShow)

        i got an error that tells me the above code is incorrect, that the sub or fuction is not defined help!!!!!!!!!!! !
        You are getting this Error because your API is declared Privately as opposed to Publically. Declare it as:
        Code:
        Public Declare Function apiShowWindow Lib "user32" _
        Alias "ShowWindow" (ByVal hWnd As Long, _
        ByVal nCmdShow As Long) As Long

        Comment

        • Denburt
          Recognized Expert Top Contributor
          • Mar 2007
          • 1356

          #19
          Glad you got it, glad we were able to help.

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #20
            Originally posted by Denburt
            Glad you got it, glad we were able to help.
            That is why we are here, agreed?

            Comment

            • Denburt
              Recognized Expert Top Contributor
              • Mar 2007
              • 1356

              #21
              Originally posted by ADezii
              That is why we are here, agreed?
              Positively absolutely, I love what I do and enjoy sharing the info, hopefully someone can learn from the knowledge I have obtained. I know that it sure helps me and I learn as well.

              Comment

              • rockdc1981
                New Member
                • Apr 2007
                • 51

                #22
                Originally posted by Denburt
                Positively absolutely, I love what I do and enjoy sharing the info, hopefully someone can learn from the knowledge I have obtained. I know that it sure helps me and I learn as well.

                you guys are great, i was able to use the code on my welcome screen, but it takes sometime to load the form.

                Comment

                • Hutch
                  New Member
                  • Mar 2007
                  • 74

                  #23
                  Originally posted by rockdc1981
                  you guys are great, i was able to use the code on my welcome screen, but it takes sometime to load the form.

                  Currently i have four individuals with a fifth who sometimes runs the program. And it takes a second or so once three users are already on it but once the users are on thier forms and entering data there is no lag time.

                  Comment

                  • Mojito05
                    New Member
                    • Apr 2007
                    • 1

                    #24
                    I'm using this on a couple of forms in A2002 and it's working great. Although, there's 1 more thing I'd like to do, that I can't figure out.

                    Like some other people who are using this code, I'm trying to make my database as airtight as possible to keep users from getting into things - accidentally or intentionally.

                    For reference, here are some of the properties from the main form:

                    Pop Up: Yes
                    Modal: Yes
                    Border Style: Yes
                    Control Box: No
                    On Open: [Event Procedure]
                    Private Sub Form_Open(Cance l As Integer)
                    Me.TimerInterva l = 1
                    End Sub
                    On Timer: [Event Procedure]
                    Private Sub Form_Timer()
                    Me.TimerInterva l = 0
                    fSetAccessWindo w (SW_HIDE)
                    End Sub
                    I also un-checked all of the check boxes in the database's Startup options menu. I then added a button to the form so that the user can close the database, and another button so that the form can minimized. I made the minimize button so that when it was used, something would show-up on the taskbar and not on the desktop (above the Start button). I figured the users would get confused when they had multiple windows open and couldn't find the database on the taskbar. Here's the code I put in the minimize button's On Click event:
                    Private Sub Image37_Click()
                    Dim stDocName As String
                    Dim stLinkCriteria As String

                    Me.Form.Modal = False
                    stDocName = "MinimizeFo rm"
                    DoCmd.OpenForm stDocName, , , stLinkCriteria
                    fSetAccessWindo w (SW_SHOWMINIMIZ ED)

                    Exit_Image37_Cl ick:
                    Exit Sub

                    Err_Image37_Cli ck:
                    MsgBox Err.Description
                    Resume Exit_Image37_Cl ick

                    End Sub
                    But once the form is minimized (I realize that it's really the main database window that's minimized, because that's what's shown on the taskbar), is there a way to maximize/re-open the form (just like it is when it's initially opened) without the main database showing-up? I tried, but I couldn't figure out a way to use SetAccessWindow (SW_HIDE) again.

                    So anyway, sorry for the long explanation, but just let me know if anyone has any questions or ideas.

                    Thanks.

                    Comment

                    • Hutch
                      New Member
                      • Mar 2007
                      • 74

                      #25
                      Originally posted by Mojito05
                      I'm using this on a couple of forms in A2002 and it's working great. Although, there's 1 more thing I'd like to do, that I can't figure out.

                      Like some other people who are using this code, I'm trying to make my database as airtight as possible to keep users from getting into things - accidentally or intentionally.

                      For reference, here are some of the properties from the main form:

                      Pop Up: Yes
                      Modal: Yes
                      Border Style: Yes
                      Control Box: No
                      On Open: [Event Procedure]
                      Private Sub Form_Open(Cance l As Integer)
                      Me.TimerInterva l = 1
                      End Sub
                      On Timer: [Event Procedure]
                      Private Sub Form_Timer()
                      Me.TimerInterva l = 0
                      fSetAccessWindo w (SW_HIDE)
                      End Sub
                      I also un-checked all of the check boxes in the database's Startup options menu. I then added a button to the form so that the user can close the database, and another button so that the form can minimized. I made the minimize button so that when it was used, something would show-up on the taskbar and not on the desktop (above the Start button). I figured the users would get confused when they had multiple windows open and couldn't find the database on the taskbar. Here's the code I put in the minimize button's On Click event:
                      Private Sub Image37_Click()
                      Dim stDocName As String
                      Dim stLinkCriteria As String

                      Me.Form.Modal = False
                      stDocName = "MinimizeFo rm"
                      DoCmd.OpenForm stDocName, , , stLinkCriteria
                      fSetAccessWindo w (SW_SHOWMINIMIZ ED)

                      Exit_Image37_Cl ick:
                      Exit Sub

                      Err_Image37_Cli ck:
                      MsgBox Err.Description
                      Resume Exit_Image37_Cl ick

                      End Sub
                      But once the form is minimized (I realize that it's really the main database window that's minimized, because that's what's shown on the taskbar), is there a way to maximize/re-open the form (just like it is when it's initially opened) without the main database showing-up? I tried, but I couldn't figure out a way to use SetAccessWindow (SW_HIDE) again.

                      So anyway, sorry for the long explanation, but just let me know if anyone has any questions or ideas.

                      Thanks.

                      This is a very good question and something i'm very interested in, however since this conversation is based on hidding the access window and doesnt focus on your question exactly i'm reposting it back in the forum so people will see it and answer your question.

                      Comment

                      • pmayall
                        New Member
                        • Sep 2007
                        • 3

                        #26
                        As a complete newy,
                        where would i paste the below code, as i have tryed and cant get it to work,

                        Private Sub Form_Load()
                        Call fSetAccessWindo w(0)
                        End Sub
                        Please help i have been trying for hours.

                        Comment

                        • pmayall
                          New Member
                          • Sep 2007
                          • 3

                          #27
                          OK now i am in trouble,
                          this works great as i got it to work. Know i cant work out how to get it back so i can work on the database???

                          Big help required.

                          Comment

                          • Denburt
                            Recognized Expert Top Contributor
                            • Mar 2007
                            • 1356

                            #28
                            This question was followed up in the following thread:


                            I found a resolution utilizing the following article. Just check to see if the MS Access application is in the state you want. If it isn't then change the app state. This link utilizes some of the functions/code from earlier in this thread so don't confuse yourself by just doing a copy and paste since you would likely end up declaring the same function twice.

                            Comment

                            • Denburt
                              Recognized Expert Top Contributor
                              • Mar 2007
                              • 1356

                              #29
                              FYI if you just want to view the Main database window for some temp maintenance you should be able to just hold the shift key down when starting the app and bypass the main startup form, unless of course you have this feature disabled, in which case you might need to call it from another app (I had to once) to re enable this feature.

                              Comment

                              • pmayall
                                New Member
                                • Sep 2007
                                • 3

                                #30
                                Originally posted by Denburt
                                FYI if you just want to view the Main database window for some temp maintenance you should be able to just hold the shift key down when starting the app and bypass the main startup form, unless of course you have this feature disabled, in which case you might need to call it from another app (I had to once) to re enable this feature.
                                I am not sure weather you get me,
                                I have used the code above to close the application window, i have tryed shift key, how do i call it from another app?

                                Comment

                                Working...