473,383 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Hide Access Window

74
!!!!FIRST!!! The fallowing code gets placed into a module that has to be called "SetAccessWindow"

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

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


!!!SECOND!!! you have to paste this code into every form

Private Sub Form_Load()
Call fSetAccessWindow(0)
End Sub



The above code works great on forms, but i cant get it to function on Reports. Help?
Apr 6 '07 #1
29 15341
ADezii
8,834 Expert 8TB
!!!!FIRST!!! The fallowing code gets placed into a module that has to be called "SetAccessWindow"

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

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


!!!SECOND!!! you have to paste this code into every form

Private Sub Form_Load()
Call fSetAccessWindow(0)
End Sub



The above code works great on forms, but i cant get it to function on Reports. Help?
The 'Handle' to a Report Window is defined by its hWnd Property. Are you properly passing this value to the API Function, something similar to:
Expand|Select|Wrap|Line Numbers
  1. loX = apiShowWindow(Reports!rptYourReport.hWnd, nCmdShow)
Apr 7 '07 #2
Hutch
74
loX = apiShowWindow(Reports!rptYourReport.hWnd, nCmdShow)

I tried pasting the above in the code were i saw it begin with "lox=" but no success. do i need to write this code for every report i have a place the report name in "rptYourReport"?

I use this code just the way you see it at the top of this page and it works on all my forms just fine, could it have something to do with the "form" verbage used through out the code? i tried changing this to "report" and still had no luck.
Apr 7 '07 #3
ADezii
8,834 Expert 8TB
loX = apiShowWindow(Reports!rptYourReport.hWnd, nCmdShow)

I tried pasting the above in the code were i saw it begin with "lox=" but no success. do i need to write this code for every report i have a place the report name in "rptYourReport"?

I use this code just the way you see it at the top of this page and it works on all my forms just fine, could it have something to do with the "form" verbage used through out the code? i tried changing this to "report" and still had no luck.
__1. The Reports must be Open for the code to work.
__2. You need only pass the 'Handle' of the open Report to the API Function:
Expand|Select|Wrap|Line Numbers
  1. Dim intHandle As Long
  2. intHandle = Reports!rptYourReport.hWnd OR Me.hWnd (in proper context)
  3. loX = apiShowWindow(intHandle, nCmdShow)
__3. As far as apiShowWindow() is concerned, it only needs a Long Integer representing the Handle of the Report and a Parameter indicating what it should do with this Window (Report)
Apr 7 '07 #4
ADezii
8,834 Expert 8TB
loX = apiShowWindow(Reports!rptYourReport.hWnd, nCmdShow)

I tried pasting the above in the code were i saw it begin with "lox=" but no success. do i need to write this code for every report i have a place the report name in "rptYourReport"?

I use this code just the way you see it at the top of this page and it works on all my forms just fine, could it have something to do with the "form" verbage used through out the code? i tried changing this to "report" and still had no luck.
I have made the assumption that you have modified the following lines of code to reference a Report and not a Form, have you?

Function fSetAccessWindow(nCmdShow As Long)
Set loform = Screen.ActiveForm

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
End If
End Function
Apr 7 '07 #5
Hutch
74
Yes i changed all the verbage of "Form" to "Report" Example

Dim loX As Long
Dim loform As Form
On Error Resume Next
Set loform = Screen.ActiveForm

is now

Dim loX As Long
Dim loform As Report
On Error Resume Next
Set loform = Screen.ActiveReport

but i cant seem to find the following code to change that you call out in your last reply

"Dim intHandle As Long
intHandle = Reports!rptYourReport.hWnd OR Me.hWnd (in proper context)
loX = apiShowWindow(intHandle, nCmdShow)"
Apr 9 '07 #6
Hutch
74
After all these changes the code does not work on the reports but still works on the forms. argh!


Thank you so much for all your help.
Apr 9 '07 #7
Denburt
1,356 Expert 1GB
Interesting approach, I was also able to utilize it for my forms but not the reports, it must have something to do with the fact that reports are handled differently...
Apr 9 '07 #8
Hutch
74
I still need help figuring this code out
Apr 9 '07 #9
ADezii
8,834 Expert 8TB
Interesting approach, I was also able to utilize it for my forms but not the reports, it must have something to do with the fact that reports are handled differently...
Denburt, just for your own information:
I had absolutely no problem opening a Report called Report1, then executing the following code in the Click() Event of a Command Button. The end result was that that Report1 was now hidden. I did call the API Function directly:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTestButton_Click()
  2.   Dim loX As Long
  3.   loX = apiShowWindow(Reports!Report1.hWnd, 0)
  4. End Sub
Apr 9 '07 #10
Hutch
74
i dont want to hide the report, i want to have everything behind the report hidden i.e. access window.
Apr 9 '07 #11
Denburt
1,356 Expert 1GB
I could be mistaken but from what I think you want you are trying to hide the MS Access application but still show reports forms etc. correct?

If this is so then you left out a couple of key pieces of info that would help us understand... Your forms are set to popup and Modal correct?

Using the on_load event allows the following to work...

screen.activeform

However since a report does not have an onload event you need to specify which report you are using. I also modified it a bit by grabbing the hwnd of the report itself.


Expand|Select|Wrap|Line Numbers
  1. 'In the declaration section of your module.
  2. Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long
  3.  
  4. Function rSetAccessWindow(nCmdShow As Long, Optional myRep As Report)
  5. Dim loX As Long
  6.  Dim intWindowHandle As Long
  7. If nCmdShow = SW_SHOWMINIMIZED And myRep.Modal = True Then
  8.     MsgBox "Cannot minimize Access with " _
  9.     & (myRep.Caption + " ") _
  10.     & "report on screen"
  11. ElseIf nCmdShow = SW_HIDE And myRep.PopUp <> True Then
  12.     MsgBox "Cannot hide Access with " _
  13.     & (myRep.Caption + " ") _
  14.     & "report on screen"
  15. Else
  16.     loX = apiShowWindow(hWndAccessApp, nCmdShow)
  17. End If
  18.  
  19. rSetAccessWindow = (loX <> 0)
  20.     intWindowHandle = myRep.hWnd
  21.     If Not IsZoomed(intWindowHandle) Then
  22.  
  23. DoCmd.Maximize
  24.     End If
  25. End Function
  26.  
Good luck
Apr 9 '07 #12
Hutch
74
where do i specifiy the report?
Apr 9 '07 #13
Denburt
1,356 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2. Call rSetAccessWindow(0, Me)
  3. End sub
Apr 9 '07 #14
Hutch
74
loX = apiShowWindow(hWndAccessApp, nCmdShow)

i got an error that tells me the above code is incorrect, that the sub or fuction is not defined help!!!!!!!!!!!!
Apr 9 '07 #15
Hutch
74
Got it to work, Really have no idea but it works!! Thanks
Apr 9 '07 #16
Denburt
1,356 Expert 1GB
Your module "SetAccessWindow"

Should look something like this"
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Global Const SW_HIDE = 0
  5. Global Const SW_SHOWNORMAL = 1
  6. Global Const SW_SHOWMINIMIZED = 2
  7. Global Const SW_SHOWMAXIMIZED = 3
  8. Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long
  9. Private Declare Function apiShowWindow Lib "user32" _
  10. Alias "ShowWindow" (ByVal hWnd As Long, _
  11. ByVal nCmdShow As Long) As Long
  12. Function fSetAccessWindow(nCmdShow As Long)
  13.  
  14. Dim loX As Long
  15. Dim loform As Form
  16. On Error Resume Next
  17. Set loform = Screen.ActiveForm
  18.  
  19. If Err <> 0 Then
  20. loX = apiShowWindow(hWndAccessApp, nCmdShow)
  21. Err.Clear
  22. End If
  23.  
  24. If nCmdShow = SW_SHOWMINIMIZED And loform.Modal = True Then
  25. MsgBox "Cannot minimize Access with " _
  26. & (loform.Caption + " ") _
  27. & "form on screen"
  28. ElseIf nCmdShow = SW_HIDE And loform.PopUp <> True Then
  29. MsgBox "Cannot hide Access with " _
  30. & (loform.Caption + " ") _
  31. & "form on screen"
  32. Else
  33. loX = apiShowWindow(hWndAccessApp, nCmdShow)
  34. End If
  35. fSetAccessWindow = (loX <> 0)
  36. End Function
  37. Function rSetAccessWindow(nCmdShow As Long, Optional myRep As Report)
  38. Dim loX As Long
  39.  Dim intWindowHandle As Long
  40. If nCmdShow = SW_SHOWMINIMIZED And myRep.Modal = True Then
  41.     MsgBox "Cannot minimize Access with " _
  42.     & (myRep.Caption + " ") _
  43.     & "report on screen"
  44. ElseIf nCmdShow = SW_HIDE And myRep.PopUp <> True Then
  45.     MsgBox "Cannot hide Access with " _
  46.     & (myRep.Caption + " ") _
  47.     & "report on screen"
  48. Else
  49.     loX = apiShowWindow(hWndAccessApp, nCmdShow)
  50. End If
  51.  
  52. rSetAccessWindow = (loX <> 0)
  53.     intWindowHandle = myRep.hWnd
  54.     If Not IsZoomed(intWindowHandle) Then
  55.  
  56. DoCmd.Maximize
  57.     End If
  58. End Function
  59.  
  60. !!!SECOND!!! you have to paste this code into every form
  61.  
  62. Private Sub Form_Load()
  63. Call fSetAccessWindow(0)
  64. End Sub
  65.  
  66. In each report you need to enter the following:
  67.  
  68. Private Sub Report_Open(Cancel As Integer)
  69. Call rSetAccessWindow(0, Me)
  70. End sub
  71.  
  72.  
Apr 9 '07 #17
ADezii
8,834 Expert 8TB
loX = apiShowWindow(hWndAccessApp, 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:
Expand|Select|Wrap|Line Numbers
  1. Public Declare Function apiShowWindow Lib "user32" _
  2. Alias "ShowWindow" (ByVal hWnd As Long, _
  3. ByVal nCmdShow As Long) As Long
Apr 9 '07 #18
Denburt
1,356 Expert 1GB
Glad you got it, glad we were able to help.
Apr 10 '07 #19
ADezii
8,834 Expert 8TB
Glad you got it, glad we were able to help.
That is why we are here, agreed?
Apr 10 '07 #20
Denburt
1,356 Expert 1GB
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.
Apr 10 '07 #21
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.
Apr 16 '07 #22
Hutch
74
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.
Apr 17 '07 #23
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(Cancel As Integer)
Me.TimerInterval = 1
End Sub
On Timer: [Event Procedure]
Private Sub Form_Timer()
Me.TimerInterval = 0
fSetAccessWindow (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 = "MinimizeForm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
fSetAccessWindow (SW_SHOWMINIMIZED)

Exit_Image37_Click:
Exit Sub

Err_Image37_Click:
MsgBox Err.Description
Resume Exit_Image37_Click

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.
Apr 24 '07 #24
Hutch
74
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(Cancel As Integer)
Me.TimerInterval = 1
End Sub
On Timer: [Event Procedure]
Private Sub Form_Timer()
Me.TimerInterval = 0
fSetAccessWindow (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 = "MinimizeForm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
fSetAccessWindow (SW_SHOWMINIMIZED)

Exit_Image37_Click:
Exit Sub

Err_Image37_Click:
MsgBox Err.Description
Resume Exit_Image37_Click

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.
May 1 '07 #25
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 fSetAccessWindow(0)
End Sub
Please help i have been trying for hours.
Sep 27 '07 #26
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.
Sep 27 '07 #27
Denburt
1,356 Expert 1GB
This question was followed up in the following thread:
http://www.thescripts.com/forum/thread640403.html

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.

http://support.microsoft.com/kb/210118
Sep 27 '07 #28
Denburt
1,356 Expert 1GB
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.
Sep 27 '07 #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.
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?
Sep 28 '07 #30

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: adrien | last post by:
Hi, (also posted in netscape.public.mozilla.browser) i use netscape 7 and want to hide the scrollbars of the window when something happens. I tried this: window.scrollbars.visible=false...
2
by: Peter K | last post by:
How do I Hide/Unhide the Main Database Window in VB?
8
by: MLH | last post by:
My autoexec macro in an Access 2.0 database has 2 lines. The first runs DoMenuItem - Database - Window - Hide. The second lines is Runcode - Initialize(). Initialize is a procedure in a global...
1
by: mr.mcgrew | last post by:
Out of nowhere a database I had set to hide the DB window at startup began showing the dang window. It doesn't matter how many times I set/unset/reset the property, it has no effect. I've tried...
13
by: DS | last post by:
How do you hide the Title Bar for Access the application. I have everything done but I need to hide the title bar. I've seen code to hide Access but that seems like overkill. Can I put hiding...
9
by: Mark | last post by:
Hi All, I am trying to use the function found on the MVP site http://www.mvps.org/access/api/api0019.htm to hide the Access window. I must be missing something as I keep getting an error message:...
1
by: lauren quantrell | last post by:
Before getting pistol whipped, I know this is a well-worn topic but I don't see the answer... I know how to hide the Access window, I know how to disable the Access application's close button, but...
4
by: Blaine | last post by:
Does anyone know how I can hide a form from the TaskManager? I've set the ShowInTaskbar to False, but when using Alt-TAB to switch between applications, it appears as a blank icon. I can set it...
11
by: Nick 'The database Guy' | last post by:
Hi People, How do you go about hiding the database window. The reason for doing this is that sometimes have to manually add data to tables. I have a fully interatctive menu system from which...
5
by: xrado | last post by:
when i say window.hide(), window dont hide imidetly i want to hide it for a few seconds, do something and then show it back how can i do this? i have this example: import pygtk,time...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.