How to start with a blank main window? - ms-access

I want to write some VBA script so that when I start my access application the main window is blank. This is the list of things I need to be removed or hidden:
The entire ribbon
The status bar
The navigation pane
The window tabs
In addition, I want to disable the popup menu when right clicking.
I also want to disable SHIFT bypass key startup.
I basically want it to look like an application created with VB or C#.
Only if I login as admin will the disabled options be bypassed.

Does it need to be VBA? Why not using the normal Access Application Options?
In Access 2010 you can find them via File > Options > Current Database. Almost all the things you want can just be unchecked - see the following screenshot. The options you select there are saved with your database.
You can start the database while holding SHIFT which will override these start up options and show you your "normal" ribbon, status bar, navigation bar, ...

Try the following in startup function
This should do what you want
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.ShowToolbar "Status Bar", acToolbarNo
Might work with other MS Access windows elements, I just wanted to not display the parts above.

Old thread but still useful information. Here's what I do:
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.ShowToolbar "Status Bar", acToolbarNo
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
Put that code in a Public Sub called from a macro called AutoExec.
Disabling Window Tabs and the Shift Bypass are trickier because these need to be done by setting the database property, either through the database Properties or by appending a property with CreateProperty. Also, you need to exit and reopen the database for these changes to take effect.
I found instructions over on techrepublic and Allen Browne has more complete instructions on his website.

Actually, as noted, you can use the startup options to remove most all of the questions you have in terms of popups, the tabs etc.
To hide ribbon, qat, just use:
DoCmd.ShowToolbar "Ribbon", acToolbarNo
So, with the options setup correct and ONE line of code, you only see your form.
Here is an resulting screen shot of using the above one line of code and options to turn off tabs (you want tabbed windows, but tabs turned off). Note how you see the windows desktop. this was all done with one line of code as per above:

Related

Hiding the Navigation Pane cause a problem when exiting the database

I just found something strange with MS-Access 2016. I have a database with 2 forms: one hidden, one for a menu. The autoexec will open the hidden form and that one will open the menu form.
I unchecked some options, under Current Database e.g. [Display Navigation Pane] and [Allow Full Menus].
I have an exit button/command on the menu form. On Click, it calls DoCmd.Quit. But before exiting, I am getting an MS-Access window asking for the parameter that is normally when the form open, not when it is closing.
After doing a lot of testing and I mean a lot, I realised that the problem is related to the fact that I am disabling the [Display Navigation Pane]. If I keep the navigation pane, but instead I unchecked all Object Type, then everything works correctly.
So, my question is why disabling the navigation pane can create something like that and is there a way to fix it?
Yes, my solution works, but I don’t like it since users can open and close the navigation pane using the shutter bar; nothing shows but it is still distracting and users can call for support.
The problem is not related to the fact that the first form is hidden, but because it is open. If I add a DoCmd.Close acForm, “F_Parameter” before my DoCmd.Quit then it works.
It is easy to reproduce the problem:
Create a new database
Create two forms:
F_Parameter
F_Menu
Create a Macro named Autoexec:
OpenForm
Form Name: F_Parameter
Window Mode: Hidden
In form F_Parameter create an event On Load
Private Sub Form_Load()
DoCmd.OpenForm “F_Menu”
End Sub
In form F_Menu create a Button named Btn_Exit with an event On Click
Private Sub Btn_Exit_Click()
DoCmd.Quit
End Sub
In form F_Menu create an event On Load
Private Sub Form_Load()
MsgBox “Hello”
End Sub
go File, Options, Current Database and
uncheck Display Navigation Pane and
uncheck Allow Full Menus
Save, exit and open the database:
You will get a “Hello” because the F_Menu form open, now click on the exit and you will get another “Hello”. This second one should not be there because the form should be closing not opening.
I was able to reproduce the issue described. I don't think it has anything to do with the Navigation Pane.
This is happening because while the DoCmd.Quit event is occurring, the hidden F_Parameter form is becoming "unhidden" in order for Access to close it. This causes the F_Parameter Form.Load event to run, which is essentially opening F_Menu, thus causing the Form.Load event on F_Menu to run.
I was able to solve this by first explicitly closing F_Parameter, then quitting:
DoCmd.Close ObjectType:=acForm, ObjectName:="F_Parameter", Save:=acSaveNo
DoCmd.Quit

When printing a Access Report that's open in Preview, why is it printing contents of a table?

I have a report Open in Print Preview mode. I have accomplished this using a button with the code:
DoCmd.OpenReport "rptNameHere", acViewPreview, "", "", acNormal
When I print using Ctrl+P, the report prints as expected. When I go to File>Print however, it sends the contents of a table to the printer. The table it prints is currently selected in the Navigation Pane, and the program is for some reason ignoring the currently open window. This happens for each different report that I open in this same manner.
Is there anyway to fix this behavior? This database will be distributed in .accde format with the Navigation Pane hidden. That particular table will always be selected by default because it is the top object in the pane.
I'm guessing the answer is one of three options: 1) When I Open a report using my On-Click event, some sort of code to also select it in the Navigation Pane; 2) An option or code somewhere that will force the program to print the open window and not the selected table; 3) A way to remove the Print entry from the File menu so the only option is for users to print with Ctrl+P.
Edit: Using Access 2016, which may make a difference. I've also confirmed this happends regardless of what is currently selected in the Navigation Pane, that item is what is sent to the printer.
Edit 2: I think this has to do with my Forms/Reports that have the "Pop Up" set to Yes. For any of those, the problem occurs. Whenever "Pop Up" is set to No, it does not.

lock navigate pane in ms access

We are working on a project in MS-Access 2010, where users will be using switchboard as a main menu for navigation and will work in forms. We protected each form with login and password so the user can only access his/her records in a form (using vba macro inside MS-Access).
Now we would like to lock the control pane so noone can access objects like tables and queries. Does anyone have an idea how to do it in MS-Access?
Thanks for any ideas.
Home>Options>CurrentDatabase>
uncheck 'Use Access special keys'
uncheck 'Display Navigation Pane'
And perhaps also:
uncheck 'Allow full menus'
uncheck 'Allow default shortcut menus'
build custom ribbon
make sure users don't know about shift key bypass or else distribute executable ACCDE
if you are looking to do this programatically, then this will do it:
Call DoCmd.LockNavigationPane(True)
however, you are probably better off hiding the navigation window and also following some of the suggestions by June7.
An easy solution couild be simply setting the forms modal property to true in the form opening event like so:
Private Sub Form_Open(Cancel As Integer)
' Go Modal to Lock Navigation Pane
Me.Form.Modal = True
' Hide Navigation Pane
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
' Hide Ribbon
DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Sub
Granted setting a form to Modal may not fit every situation but if you have a startup/ switchboard style form which opens all other forms then this could be a solution for you.

Prevent 'save design changes' for an open form when closing Access

I have a split form as my main interface in an Access 2010 application. As normal, users are able to resize the datasheet portion, reorder columns, etc.
However, I don't want them to save such changes when leaving the form. Each time the form is opened the default format should be loaded.
I've taken care of all but one closing method. To avoid them closing using the default close button I've set Border Style = None. Instead I have a Close Form button that uses DoCmd.CLOSE acForm, "Main_form", acSaveNo
But if the user clicks the close button for the Access application, it pops the 'Do you want to save changes to the design of form` dialog like always.
I looked into disabling the application's Close button, but messing with Windows API is beyond my skill (and there should be a way to accomplish this without going to extreme measures).
I found a way to do this. A combination of database options, form format options, and vba can do it.
Go to the 'Current Database' options screen in the main Access
options and uncheck 'Enable design changes in Datasheet view'. This will prevent all datasheet view design changes in the database, so you will have to go into design mode for any table changes. Users can still reorder and resize columns within a form, but Access no longer considers that a valid design change and will not prompt to save it no matter how you close the form
Set the form format property 'Save Splitter Bar Position' = No. The form will now clear any change to the bar location when the form is closed. Access got really weird on me about this setting, however. Once I had ever set the option to no, I could no longer use design view or layout view to set a new default bar position; it always reverted to the location where it was when I first tried this setting. Even resetting the option to Yes, saving the design change, and fully exiting the database did not fix this.
So I added an On Load event to reset the split form size when the form opens: Me.SplitFormSize = 9000. The numbers involved are surprisingly high; in the form properties list this is set in inches. Mine was 6.5", which apparently translates to 9000.
With these three changes (along with the steps I detailed in the question) Access no longer prompts to save design changes when the form is closed, even if the user is closing the Access application entirely. The form also snaps the split form bar back to where it should be on load.
Since the API is beyond my skill too, here is a left-field workaround.
Duplicate Main_Form and rename it "Main_Form_Template". Create an Autoexec module or edit an existing one and add:
DoCmd.DeleteObject acForm, "Main_Form"
DoCmd.CopyObject , "Main_Form", acForm, "Main_Form_Template"
That should reinstate the standard template for the user each time they open the database even if they were to save the form when closing Access.
Turn your close button off on the form.
On the form's property sheet, format tab, about 2/3 of way down. Set Close Button = No
This forces the user to close it via the button you created.

Form Open is hiding and disabling the Navigation Pane

I am debugging an access application built by another developer. As I debug, I want to be able to see the results of specific queries and tables as I go. On one particular form, the navigation pane (which includes the list of tables, queries, forms...etc) is minimized and disabled any time the form is open. The navigation then maximizes and is fully restored when the form is closed or in design mode.
I've searched throughout the VBA and there doesn't seem to be anything that's controlling this behavior. I know there is some VBA that can do this like
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.RunCommand acCmdWindowHide
but none of these can be found in the code behind. Any idea what else might be causing this?
The Modal property of the Form will cause such behavior when set to true.
You can set that property on the property sheet for that form in the "Other" tab. It can be set by VBA-Code with code like this:
Forms("yourForm").Modal = True '(or False to disable)