!!!!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?
29 15342
!!!!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: - loX = apiShowWindow(Reports!rptYourReport.hWnd, nCmdShow)
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.
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: - Dim intHandle As Long
-
intHandle = Reports!rptYourReport.hWnd OR Me.hWnd (in proper context)
-
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)
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
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)"
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.
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...
I still need help figuring this code out
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: - Private Sub cmdTestButton_Click()
-
Dim loX As Long
-
loX = apiShowWindow(Reports!Report1.hWnd, 0)
-
End Sub
i dont want to hide the report, i want to have everything behind the report hidden i.e. access window.
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. -
'In the declaration section of your module.
-
Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long
-
-
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
-
Good luck
where do i specifiy the report?
- Private Sub Report_Open(Cancel As Integer)
-
Call rSetAccessWindow(0, Me)
-
End sub
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!!!!!!!!!!!!
Got it to work, Really have no idea but it works!! Thanks
Your module "SetAccessWindow"
Should look something like this" -
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
-
-
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: - Public Declare Function apiShowWindow Lib "user32" _
-
Alias "ShowWindow" (ByVal hWnd As Long, _
-
ByVal nCmdShow As Long) As Long
Glad you got it, glad we were able to help.
Glad you got it, glad we were able to help.
That is why we are here, agreed?
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.
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.
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.
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.
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.
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.
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.
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
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.
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?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Peter K |
last post by:
How do I Hide/Unhide the Main Database Window in VB?
|
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...
|
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...
|
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...
|
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:...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |