If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Menu bar not showing after API Call
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 ********** -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#2
|
|||
|
|||
Menu bar not showing after API Call
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" u46942@uwe wrote in message news:a32e45a710cba@uwe... 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 ********** -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#3
|
|||
|
|||
Menu bar not showing after API Call
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. Arvin Meyer [MVP] wrote: 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 ********** -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#4
|
|||
|
|||
Menu bar not showing after API Call
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 Arvin Meyer [MVP] wrote: 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 ********** -- Message posted via http://www.accessmonster.com |
#5
|
|||
|
|||
Menu bar not showing after API Call
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. Arvin Meyer [MVP] wrote: 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 ********** -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#6
|
|||
|
|||
Menu bar not showing after API Call
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" u46942@uwe wrote in message news:a3318db9a7a7a@uwe... 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 Arvin Meyer [MVP] wrote: 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 ********** -- Message posted via http://www.accessmonster.com |
#7
|
|||
|
|||
Menu bar not showing after API Call
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" u46942@uwe wrote in message news:a332a03035775@uwe... 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. Arvin Meyer [MVP] wrote: 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 ********** -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#8
|
|||
|
|||
Menu bar not showing after API Call
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. Arvin Meyer [MVP] wrote: 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] '************ Code End ********** -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
Thread Tools | |
Display Modes | |
|
|