Menu bar not showing after API Call

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that maximizes
the screen. It is from a Login form that puts the form on the desktop. These
are the two routines that I'm using. The problem is that when Access Hides
and then reopens [Maximizes] it maximizes so big that none of the menus are
showing. Not even my custom menu which I need. Maybe there's something in the
code that shuts out everything else. I don't know

Private Sub Form_Open(Cancel As Integer)
10 On Error GoTo ErrorPoint
DoCmd.RunCommand acCmdSizeToFitForm 'Sets up the Login Screen

Me.Visible = True
DoEvents
fSetAccessWindow (SW_HIDE)

ExitPoint:
40 Exit Sub

ErrorPoint:
50 MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
60 Resume ExitPoint

End Sub


Private Sub Form_Close()
fSetAccessWindow (SW_SHOWMAXIMIZED)
40 Me.Visible = False
50 Application.CommandBars("myMenu").Enabled = True
70 DoCmd.OpenForm "frmLinkToDatabases"

End Sub


This is the API:
'************ 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

'************ Code Start **********
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

Arvin Meyer [MVP]

Maybe it's because you hid it? Ya think?

Try sticking this in a standard module named Utilities, and running it from
the Debug (Immediate) window:

Function ShowMenu()
On Error Resume Next
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Afrosheen via AccessMonster.com said:
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that
maximizes
the screen. It is from a Login form that puts the form on the desktop.
These
are the two routines that I'm using. The problem is that when Access Hides
and then reopens [Maximizes] it maximizes so big that none of the menus
are
showing. Not even my custom menu which I need. Maybe there's something in
the
code that shuts out everything else. I don't know

Private Sub Form_Open(Cancel As Integer)
10 On Error GoTo ErrorPoint
DoCmd.RunCommand acCmdSizeToFitForm 'Sets up the Login Screen

Me.Visible = True
DoEvents
fSetAccessWindow (SW_HIDE)

ExitPoint:
40 Exit Sub

ErrorPoint:
50 MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
60 Resume ExitPoint

End Sub


Private Sub Form_Close()
fSetAccessWindow (SW_SHOWMAXIMIZED)
40 Me.Visible = False
50 Application.CommandBars("myMenu").Enabled = True
70 DoCmd.OpenForm "frmLinkToDatabases"

End Sub


This is the API:
'************ 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

'************ Code Start **********
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

Afrosheen via AccessMonster.com

Thanks for getting back to me Marvin. When I run Access and look at the
window, the custom menu is there. I also have it in the start program under
Menu Bar, Allow full menus, and allow short cut menus are checked also.
Maybe it's because you hid it? Ya think?

Try sticking this in a standard module named Utilities, and running it from
the Debug (Immediate) window:

Function ShowMenu()
On Error Resume Next
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that
[quoted text clipped - 97 lines]
'************ Code End **********
 
A

Afrosheen via AccessMonster.com

Arvin. I put the code as per your instructions and ran it in the immediate
window and it gave me an:

Ambigous name detected: ShowMenu
Maybe it's because you hid it? Ya think?

Try sticking this in a standard module named Utilities, and running it from
the Debug (Immediate) window:

Function ShowMenu()
On Error Resume Next
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that
[quoted text clipped - 97 lines]
'************ Code End **********
 
A

Afrosheen via AccessMonster.com

I found out where the ambigious statement was. It seems I already had that
statement in a function. But that still didn't work when I called the
statement.
Maybe it's because you hid it? Ya think?

Try sticking this in a standard module named Utilities, and running it from
the Debug (Immediate) window:

Function ShowMenu()
On Error Resume Next
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that
[quoted text clipped - 97 lines]
'************ Code End **********
 
A

Arvin Meyer [MVP]

You may have saved the module with the same name as the function. Change the
module name.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Afrosheen via AccessMonster.com said:
Arvin. I put the code as per your instructions and ran it in the immediate
window and it gave me an:

Ambigous name detected: ShowMenu
Maybe it's because you hid it? Ya think?

Try sticking this in a standard module named Utilities, and running it
from
the Debug (Immediate) window:

Function ShowMenu()
On Error Resume Next
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that
[quoted text clipped - 97 lines]
'************ Code End **********
 
A

Arvin Meyer [MVP]

Try changing the line where you maximize to:

SW_SHOWNORMAL

You can maximize or restore your application with a simple:

DoCmd.Maximize

DoCmd.Restore
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Afrosheen via AccessMonster.com said:
I found out where the ambigious statement was. It seems I already had that
statement in a function. But that still didn't work when I called the
statement.
Maybe it's because you hid it? Ya think?

Try sticking this in a standard module named Utilities, and running it
from
the Debug (Immediate) window:

Function ShowMenu()
On Error Resume Next
DoCmd.ShowToolBar "Menu Bar", acToolbarYes
End Function
Thanks for reading this.
I'm trying to get my custom menu bar working after an API call that
[quoted text clipped - 97 lines]
'************ Code End **********
 
A

Afrosheen via AccessMonster.com

Good morning Arvin,

Using the SW_SWOWNORMAL appeared to make it work. I also had to put:

Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

On Open statement to make sure the menu didn't show up. [Still under testing]

and,
Application.CommandBars("myMenu").Enabled = True

Thanks for your help.
Try changing the line where you maximize to:

SW_SHOWNORMAL

You can maximize or restore your application with a simple:

DoCmd.Maximize

DoCmd.Restore
I found out where the ambigious statement was. It seems I already had that
statement in a function. But that still didn't work when I called the
[quoted text clipped - 15 lines]
 

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