Showing form on Taskbar when application is hidden (1 Viewer)

Songs

New member
Local time
Today, 16:54
Joined
Nov 2, 2017
Messages
4
So i've been trying to get the code on this example to work:

Code:
Option Compare Database

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3

'###############################################
#If VBA7 Then
    Private Declare PtrSafe Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
#ElseIf Win64 Then 'need datatype LongPtr
    Private Declare PtrSafe Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As LongPtr, ByVal nCmdShow As LongPtr) As LongPtr
#Else '32-bit Office
    Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
#End If
'###############################################

Function SetAccessWindow(nCmdShow As Long)

    'Usage Examples
    'Maximize window:
    ' ?SetAccessWindow(SW_SHOWMAXIMIZED)
    'Minimize window:
    ' ?SetAccessWindow(SW_SHOWMINIMIZED)
    'Hide window:
    ' ?SetAccessWindow(SW_HIDE)
    'Normal window:
    ' ?SetAccessWindow(SW_SHOWNORMAL)
    
    Dim loX As Long
   ' Dim loForm As Form
    On Error Resume Next
    
    loX = apiShowWindow(hWndAccessApp, nCmdShow)
    SetAccessWindow = (loX <> 0)

End Function

I currently just use a simple button to execute SW_HIDE, but this also removes access and the form from the task bar, I was wondering if there is a way to keep the form on the task bar?

Thanks in advance.
 

isladogs

MVP / VIP
Local time
Today, 16:54
Joined
Jan 14, 2017
Messages
18,186
Hi & welcome to AWF

Counter-intuitively you need to use SW_SHOWMINIMIZED not SW_HIDE

As you've found out SWHIDE literally hides all traces of the application

The following will hide the open form and application window but leave the taskbar icon in place. Add the code to a button event or to the Form_Load event as appropriate

Code:
SetAccessWindow (SW_SHOWMINIMIZED)
DoCmd.OpenForm "MyFormName", , , , , acHidden

or use

Code:
SetAccessWindow (SW_SHOWMINIMIZED)
   DoCmd.OpenForm Me.Name, , , , , acHidden

Clicking the taskbar icon will of course restore the form

For more 'tricks' of this kind see this sample database item
https://www.access-programmers.co.uk/forums/showthread.php?t=293584
 

Songs

New member
Local time
Today, 16:54
Joined
Nov 2, 2017
Messages
4
Hi & welcome to AWF

Counter-intuitively you need to use SW_SHOWMINIMIZED not SW_HIDE

As you've found out SWHIDE literally hides all traces of the application

The following will hide the open form and application window but leave the taskbar icon in place. Add the code to a button event or to the Form_Load event as appropriate

Code:
SetAccessWindow (SW_SHOWMINIMIZED)
DoCmd.OpenForm "MyFormName", , , , , acHidden

or use

Code:
SetAccessWindow (SW_SHOWMINIMIZED)
   DoCmd.OpenForm Me.Name, , , , , acHidden

Clicking the taskbar icon will of course restore the form

For more 'tricks' of this kind see this sample database item

Thanks for your help. Unfortunately this also hides minimises the form... I've played around with the SetWindow sample a fair bit but haven't been able to produce what I'm after. I'm looking to hide the background application, have the form on the task bar but not be able to open the background access application without a prompt.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 16:54
Joined
Jan 14, 2017
Messages
18,186
Thanks for your help. Unfortunately this also hides minimises the form... I've played around with the SetWindow sample a fair bit but haven't been able to produce what I'm after. I'm looking to hide the background application, have the form on the task bar but not be able to open the background access application without a prompt.

Sorry - thought that's what you wanted
The SetWindow example has a floating form with the application window hidden.
Surely that's EXACTLY what you are describing ....
 

Songs

New member
Local time
Today, 16:54
Joined
Nov 2, 2017
Messages
4
Sorry - thought that's what you wanted
The SetWindow example has a floating form with the application window hidden.
Surely that's EXACTLY what you are describing ....
Your help is much appreciated.
Sort of yes, but when using the SetWindows sample and select the access icon on the task bar, it re-opens the access application behind the form.
Is there a way to prevent complete access to the application?
 

isladogs

MVP / VIP
Local time
Today, 16:54
Joined
Jan 14, 2017
Messages
18,186
Yes.
Hide the taskbar as well.
Otherwise no.
 

vhung

Member
Local time
Today, 09:54
Joined
Jul 8, 2020
Messages
235
but when using the SetWindows sample and select the access icon on the task bar, it re-opens the access application behind the form.
great
>i used part of it now
>make codes selection for every command
 
Last edited:

vhung

Member
Local time
Today, 09:54
Joined
Jul 8, 2020
Messages
235
great
>i used part of it now
>make codes selection for every command
i also use error list
>could determined error# codes
 

Attachments

  • errorcodes.png
    errorcodes.png
    187.7 KB · Views: 259
Last edited:

vhung

Member
Local time
Today, 09:54
Joined
Jul 8, 2020
Messages
235

vhung

Member
Local time
Today, 09:54
Joined
Jul 8, 2020
Messages
235
wow
>i use 2016 version
>thanks, i'll see the content
succeeded
>32682 highest (rows for my accdb error, 3038) : edited
>glad i fixed it
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 16:54
Joined
Jan 14, 2017
Messages
18,186
succeeded
>32682 rows for my accdb error
>glad i fixed it

The first sentence is incorrect. There are 2976 error records listed when using Access 365 with the highest error number being 32682.
Also it may be a language issue but I don't see how you can say you fixed it by using my code
 

vhung

Member
Local time
Today, 09:54
Joined
Jul 8, 2020
Messages
235
Also it may be a language issue but I don't see how you can say you fixed it by using my code
well
>the codes would not run fully at first try, might not run
>i only try to analized what missed then i fixed it
>on the other way, i could trace errors now of my accdb, with that functions you shared
 

Users who are viewing this thread

Top Bottom