A.D.TEJPAL
adtp at airtelbroadband.in
Tue Nov 27 00:53:16 CST 2007
Rocky, No need to put it on every form. It is for you to decide as to which form is most convenient for carrying out this action. Typically, the switchboard form (which is usually the start up form) could be considered for such role. Best wishes, A.D.Tejpal ------------ ----- Original Message ----- From: Rocky Smolin at Beach Access Software To: 'Access Developers discussion and problem solving' Sent: Monday, November 26, 2007 21:39 Subject: Re: [AccessD] A2K7 Navigation Pane A.D.: Does the code: DoCmd.SelectObject acForm, , True DoCmd.RunCommand acCmdWindowHide have to appear in each form, or just called once from the opening form? Thanks and regards, Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.TEJPAL Sent: Tuesday, November 20, 2007 9:26 PM To: Access Developers discussion and problem solving Cc: A.D.TEJPAL Subject: Re: [AccessD] A2K7 Navigation Pane Rocky, A convenient arrangement would be to have two command buttons named CmdHide and CmdShow on a form so as to hide or show the NavPane window in Access 2007. If the user is in a position to ensure that forms group in NavPane is never put in collapsed state, the code applicable in Access 2K & 2K3, as given below, would work in A2K7 as well. Code in form's module - A2K7 (Forms group in NavPane must not be in collapsed state) ======================================== Private Sub CmdHide_Click() ' Make NavPane the active window and hide it DoCmd.SelectObject acForm, , True DoCmd.RunCommand acCmdWindowHide End Sub '------------------------------------------------------- Private Sub CmdShow_Click() DoCmd.SelectObject acForm, , True End Sub ======================================== The simple solution given above will not work if the forms group in NavPane window is in collapsed state. This is because hiding the NavPane can get implemented only if the focus stays on NavPane window during execution of acCmdWindowHide command. However when an attempt is made in Access 2007 to activate the NavPane via DoCmd.SelectObject method while the pertinent object group is in collapsed state, the focus reverts back to the active form. This results in acCmdWindowHide command taking effect on the form itself instead of the intended target (NavPane). Thus you land up with hiding the form itself, instead of the NavPane. Remedy lies in hiding all active forms and reports prior to hiding the NavPane, and thereafter, un-hiding the forms & reports. Of course no other object like table or query should be in open state. It is observed that it is not necessary to select any specific object in NavPane. This argument in DoCmd.SelectObject statement can be left blank Mere selection of a type group (acForm, acTable etc) is adequate. If the group mentioned in DoCmd.SelectObject method does not yet have any object, it will not force that group's title bar to show up in the NavPane if not already visible (otherwise it will). This however does not detract from effectiveness of proposed approach and even such an empty group serves satisfactorily as an argument to DoCmd.SelectObject method. Sample code in form's module, as given below, will ensure effective hiding / un-hiding of NavPane window under all situations, even if all object groups in NavPane are in collapsed state. Although this code is meant for Access 2007, it can be used in Access 2003 as well (statements meant for hiding / un-hiding of active forms / reports are however not needed in Access 2003). It permits unrestricted number of forms / reports to stay in open state. It is also ensured that while cycling through forms/reports for bulk hiding/ unhiding, any forms kept deliberately hidden to start with, continue in this state while other temporarily hidden objects are made visible again. Best wishes, A.D.Tejpal ------------