Hide access window (1 Viewer)

Ravi Kumar

Registered User.
Local time
Today, 14:56
Joined
Aug 22, 2019
Messages
162
This below code is hiding the window , but not opening my Login screen form ,
I have attached the form properties also , kindly verify & help me.
Code for the form.
Code:
Option Compare Database
Option Explicit

Private Sub Form_Load()
Me.TimerInterval = 3000
DoCmd.Hourglass True
End Sub


Private Sub Form_Open(Cancel As Integer)
fSetAccessWindow (SW_HIDE)
End Sub

Private Sub Form_Timer()
'Reset the Timer Value Property
If Forms![frmsplash].TimerInterval <> 0 Then
Forms![frmsplash].TimerInterval = 0
End If
DoCmd.Hourglass False
DoCmd.OpenForm "Login screen"
DoCmd.Close
End Sub
Code in module called experiment:

Code:
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

' This function is to be called as such:
' Call fSetAccessWindow (argument)
' The arguments are as follows;
' SW_HIDE - this hides the access database window
' SW_SHOWMAXIMIZED - this maximizes the window
' SW_SHOWMINIMIZED - this minimizes the window
' SW_SHOWNORMAL - this just shows (as normal) the window


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
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
 

Attachments

  • Other property sheet.JPG
    Other property sheet.JPG
    83.2 KB · Views: 271
  • Login screen format properties.jpg
    Login screen format properties.jpg
    87.8 KB · Views: 263
  • frm splash properties.JPG
    frm splash properties.JPG
    70.1 KB · Views: 285

Ravi Kumar

Registered User.
Local time
Today, 14:56
Joined
Aug 22, 2019
Messages
162
Thank you ,

I looked at your example database It is really helpful for people like us (busy in office work but want to learn acess).

However I am just asking the question as below to just get clarity.
But as attached in my image the login form is pop up only , but still opens closes itself in background .And the frmsplash remains still.
 

isladogs

MVP / VIP
Local time
Today, 09:26
Joined
Jan 14, 2017
Messages
18,186
As your splash form is also a popup, you need to close or hide or minimise it when you open the login form.
I also suggest you set Modal = No

FWIW my module code is slightly different than that you are using which I think is by Dev Ashish. I've had issues with that in the past
 

Users who are viewing this thread

Top Bottom