Got it to work, Really have no idea but it works!! Thanks
Hide Access Window
Collapse
X
-
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
-
Originally posted by HutchloX = 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!!!!!!!!!!! !
Code:Public Declare Function apiShowWindow Lib "user32" _ Alias "ShowWindow" (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long
Comment
-
Originally posted by ADeziiThat is why we are here, agreed?Comment
-
Originally posted by DenburtPositively 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
-
Originally posted by rockdc1981you 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
-
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)On Timer: [Event Procedure]
Me.TimerInterva l = 1
End SubPrivate Sub Form_Timer()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:
Me.TimerInterva l = 0
fSetAccessWindo w (SW_HIDE)
End Sub
Private Sub Image37_Click()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.
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
So anyway, sorry for the long explanation, but just let me know if anyone has any questions or ideas.
Thanks.Comment
-
Originally posted by Mojito05I'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)On Timer: [Event Procedure]
Me.TimerInterva l = 1
End SubPrivate Sub Form_Timer()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:
Me.TimerInterva l = 0
fSetAccessWindo w (SW_HIDE)
End Sub
Private Sub Image37_Click()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.
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
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
-
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
-
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
-
Originally posted by DenburtFYI 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 have used the code above to close the application window, i have tryed shift key, how do i call it from another app?Comment
Comment