Restoring MS-Access Window

J

JimP

Is there a way to force the "Database" toolbar (or any toolbar) to be
visible. e.g.
DoCmd.ShowToolBar "Database", acToolbarYes (has no affect in my situation)

I am using code below, which was obtained through this site, to hide the
MS-Access window upon opening MS-Access - but then when restoring the
window, toolbars and menubars are not visible

'************ 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 **********
 
A

Alex Dybenko

Hi,
depends on how did you hide these toolbars. if you disabled toolbars in
startup options - then, I think, there is no way to show it again, then to
restart application with other options.

else you can hide/show commandbar using CommandBars("ToolbarName").Visible=
false/true


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
J

JimP

Hi - All boxes on "Startup" are checked. Below is the code I am using
(Show), but still no luck.

===========================

Option Compare Database

Private Sub Hide_Click()
Call fSetAccessWindow(SW_HIDE)
End Sub

Private Sub Show_Click()
Call fSetAccessWindow(SW_SHOWMAXIMIZED)
DoCmd.ShowToolbar "Database", acToolbarYes
CommandBars("Database").Visible = True
End Sub

Private Sub Quit_Click()
DoCmd.Quit
End Sub

Private Sub Form_Open(Cancel As Integer)
Me.Visible = True
DoEvents
Call fSetAccessWindow(SW_HIDE)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top