Solved

Minimize an Access form to the tray?

Posted on 2008-10-10
22
468 Views
Last Modified: 2013-11-27
Is this possible?

I have a form that takes up the whole screen.  Ideally I want to start this app on startup (no problem there) and then when the user "closes" it minimizes to the tray.

Thanks,
JOe K.
0
Comment
Question by:ClaudeWalker
  • 10
  • 10
22 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 22692657
Replaced MS Access with MS SQL Server zone "It Can't Be Done"
0
 

Author Comment

by:ClaudeWalker
ID: 22692661
Sorry that I put it in the wrong zone.  I thought some of the SQL guys may know how to do it as well.

Any ideas anyone?  
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22694060
Can't be done per se.

What you *could* do is disable the close of the application and form.
Then add your own close graphic in the top right and code this to minimise the program.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:ClaudeWalker
ID: 22695008
Any idea on how to unhide after I hide this?

Is it possible to run code from a shortcut?






'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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)
'Usage Examples
'Maximize window:
'       ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
'       ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
'       ?fSetAccessWindow(SW_HIDE)
'Normal window:
'       ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX  As Long
Dim loForm As Form
    On Error Resume Next
    Set loForm = Screen.ActiveForm
    If Err <> 0 Then 'no Activeform
      If nCmdShow = SW_HIDE Then
        MsgBox "Cannot hide Access unless " _
                    & "a form is on screen"
      Else
        loX = apiShowWindow(hWndAccessApp, nCmdShow)
        Err.Clear
      End If
    Else
        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
    End If
    fSetAccessWindow = (loX <> 0)
End Function
 
'************ Code End **********

Open in new window

0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695036
You can call the function like this:

fSetAccessWindow(SW_HIDE)    'hides it

or


fSetAccessWindow(SW_SHOWMAXIMIZED)    'maximises it.

This can be done from a form open event
0
 

Author Comment

by:ClaudeWalker
ID: 22695053
The problem is that once it's hidden I can't get it unhidden.  

I don't know how to run SW_SHOWNORMAL that would unhide it from the background.
0
 

Author Comment

by:ClaudeWalker
ID: 22695065
Perhaps if I could modify the properties of a shortcut to run the fSetAccessWindow(SW_SHOWNORMAL)

Is that possible?  Can code be run from a shortcut?
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695078
How about using code to ask the user if they want to show thewindo after a set time?

In your form code that you use to hide the window, do this:

me.form.timerinterval = 10000  'set your timer to start.


Now, on the form timer event, have this code:

If msgbox("Would you like to maximise the form?", vbyesno, "Maximise") = vbYes then
fSetAccessWindow(SW_SHOWMAXIMIZED)
End if

0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695080
Also, don't "hide" the window, if you don't need to.
Minimise it:
fSetAccessWindow(SW_SHOWMINIMIZED)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695084
Aso, you'll need to reset the timer event too:

If msgbox("Would you like to maximise the form?", vbyesno, "Maximise") = vbYes then
fSetAccessWindow(SW_SHOWMAXIMIZED)
me.form.timerinterval = 0
End if

My mistake :-)
0
 

Author Comment

by:ClaudeWalker
ID: 22695115
The reason I am trying to hide and unhide is to dramatically reduce the loading time and to not have their task bar occupied when the program is minimized (I want them to think the program is closed).  Ideally I would get it to minimize to the tray but that is proving to be too difficult.

A compromise is to hide it in the back ground and then have them unhide the program using an icon on the quick launch bar.

regarding the shortcut:

I tried running a macro through a shortcut command switch but the problem is that the application is open so the macro is only run when the application is first opened.


0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695134
Instead of using a macro, have a form open when teh database loads (you can set this in your start up options).
Then you can use teh code I suggested.
0
 

Author Comment

by:ClaudeWalker
ID: 22695149
The problem is, is when the program is hidden it will not run the On Startup open form.  It only does that when the application is closed and then reopened.    
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695167
Yes it will.
The startup form code that I gave sets a timer.
The database timer event keeps running even twhen the application is hidden
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695174
Alternatively, you could close te application and use Windows Task Scheduler to open the db at a certain time...
0
 

Author Comment

by:ClaudeWalker
ID: 22695177
If it's operating on a timer then how will the user be able to open the program when they want too?


0
 

Author Comment

by:ClaudeWalker
ID: 22695183
The whole problem is that this program needs to be running the whole time but also the user needs to be able to access it at any given time of there choosing.  
0
 

Author Comment

by:ClaudeWalker
ID: 22695195
The best I have been able to do so far is to have the shortcut open minimized and then the form opens up maximized.  You can only see the access on the taskbar for a few seconds.  

The load time is still a bit of an issue.
0
 
LVL 26

Accepted Solution

by:
dannywareham earned 500 total points
ID: 22695210
If your user needs to interact with the database at any point, then it will need to be minimised.
The other alternative is to buid an actual program (exe) so that you can have a quick launch/tray icon.
I'm 99% positive that this cannot be done in Access alone.
:-(
0
 

Author Comment

by:ClaudeWalker
ID: 22695216
I think I will deal with the load time.

I really appreciate you taking to time to work with me on my problem.  

Thanks,
JOe K.
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22695225
Not a problem.
Let me know if you have any queries
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question