Solved

Minimize an Access form to the tray?

Posted on 2008-10-10
22
459 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
 

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now