How to Hide Ribbon except when deving - ms-access-2007

I am using Access 2007 and creating an invoicing system for my parent's business. When I'm developing in Access, I would like to be able to see the ribbon nav, and also the object nav over on the left. When I push it out to them for their use, I would like to hide all of that junk.
Is there an easy way to enter an access DB as a "dev" giving my all of the options, but when opened by an end user, all they see are the forms that I have AutoExec'd to open when the database is opened?

To toggle the navigation pane, I use F11. To toggle the ribbon, Ctrl+F1 --- but that minimizes the ribbon rather than hides it completely.
If you want to do similar with VBA code:
'hide the navigation pane
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide
'unhide the navigation pane
DoCmd.SelectObject acTable, , True
'hide ribbon
Docmd.ShowToolBar "Ribbon",acToolBarNo
'unhide ribbon
Docmd.ShowToolBar "Ribbon",acToolBarYes
An easy way to distinguish between the development and production versions of your application is to place them in separate folders.
If CurrentProject.Path Like "*Dev*" Then
'do what you want for development mode
Else
'do what you want for production mode
End If
If that doesn't work for you, there are many alternatives.
A table where you store the status, retrieve the status at startup, and do your adjustments based on the status.
Same approach, but using a database property instead of a table.
A module variable which your code checks to determine the status.
Those are a few, but you can come up with plenty more if you're motivated.

Related

Under Excel O365, the custom ribbon tab does not always populate

Using an .xlam project with a fully working custom ribbon, I have found that the new tab will sometimes show nothing when clicked on. It is intermittent. The global RibbonUI object is available and running an .invalidate will then show the ribbon. However, the .invlalidate attempts prior to the tab being viewed do not seem to change this behavior. I have to view the tab and then run the .invalidate manually (with a macro button) to see the ribbon appear.
I am scratching my head trying to find a slick way of making this new custom tab populate 100% of the time.
For the benefit of those that come across this issue, I have found the root cause and a solution. This is Excel O365 specific.
If you have a custom ribbon tab set up and working, try this. Open Excel, create a blank workbook, then double-click on a cell to put it in "edit mode". Click on your custom ribbon tab. Blank, right?
This "cell in edit mode" is what was causing Excel O365 to fail to show my custom ribbon. Excel O365 starts up on the "File" screen. Prior versions always opened to a blank sheet. If you click on "Blank workbook", the ribbon displays fine. If you DOUBLE-CLICK on "Blank workbook", the first click opens the workbook and the second click puts a cell into ""edit mode". In this state, clicking on your custom ribbon tab shows nothing.
The work-around
Private Sub WorkbookActivate(ByVal Wb As Workbook)
Application.SendKeys "{ESC}"
...
You may see a cell go into edit mode for one blink but it then exits edit mode. Click on your custom ribbon tab. It will now show the ribbon controls as designed.

Microsoft Access can't open a form from inside another form with doCmd.OpenForm

I'm completely new to MS Access but not to databases. I have a form that is meant to open another form through a button and users are to add records to a target table through said form. The main menu fails to open my secondary form saying "recordset is not updatable". The table that is to receive the records is editable and I can go into it and manually add records so this doesn't seem to be the problem. If I click out of the error through the error handler menu I'm taken to the form that I expected to open, but it is read only-- I can't see it's properties sheet, design view, or even change the view at all. I looked at the VBA code on the main menu and it does use doCmd.OpenForm "myForm", , , , , ,"New"
Any pointers would be really appreciated.
Right click your form and click design view. Add a button, click Cancel and name the button appropriately. Than, right-click the button and click Build Event > Code Builder > OK. Copy/paste the code below into the button click event.
Private Sub Command0_Click()
DoCmd.OpenForm "name_of_your_form"
End Sub
That should be all you need to do. Sometimes I have seen Access do some really weird stuff. If the steps I outlined here don't work, try doing a Compact and Repair to reset everything in your DB, and then add the button.

Disable right click menu of shapes

Is there a way to disable the right click menu for shapes like e.g. rectangles in VBA?
I tried:
Private Sub Workbook_Open()
' Application.WindowState = xlMaximized
Application.DisplayFullScreen = True
Application.CommandBars("Ply").Enabled = False
Application.CommandBars("Shapes").Enabled = False
End Sub
but this does not seem to work.
The right-click menu (aka, context menu) is not a Command Bar.
You may know Command Bars by their older name, Toolbars, or their newer name, Ribbons.
Although you can capture and/or disable a right-click event on a worksheet, this doesn't apply to objects like shapes.
However, you can prevent the context menu from showing by protecting the worksheet from changes (with or without a password).
If necessary you can allow some changes, but not others, to be made by the user. More information at this link.
I have attached some screenshots of my application just to describe what I want to archive.
The problem is that the menu is realy annoying when trying to select more than one shape.

Excel Addins - Not Modifying Toolbar

I am looking for the best way to deploy Excel Macros to users. My goal is to make it super easy for end users to install and promote use by adding to the addin toolbar. I know that there are a number of help articles on this topic but couldn't find anything that covered this exact issue. Can you please help and excuse me if this is a noobie question. Please see below for replication steps for my issue.
I have added the code below as a worksheet event on "This Worksheet" of an excel macro file
I add the main code to a module that it references
I save this as an .XLAM in the addin roaming folder
I enable this as an addin in EXCEL 2013
After I install it adds the button to an add in tab
It works until I close Excel in which case the button disappears
It is still under active add ins but not on the toolbar
The code:
Option Explicit
Dim cControl As CommandBarButton
Private Sub Workbook_AddinInstall()
On Error Resume Next 'Just in case
'Delete any existing menu item that may have been left.
Application.CommandBars("Worksheet Menu Bar").Controls("Super Code").Delete
'Add the new menu item and Set a CommandBarButton Variable to it
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
'Work with the Variable
With cControl
.Caption = "Convert Survey Reporter Tables"
.Style = msoButtonCaption
.OnAction = "CMB_General_Table_Formatting"
'Macro stored in a Standard Module
End With
On Error GoTo 0
End Sub
Private Sub Workbook_AddinUninstall()
On Error Resume Next 'In case it has already gone.
Application.CommandBars("Worksheet Menu Bar").Controls("Convert Survey Reporter Tables").Delete
On Error GoTo 0
End Sub
If you want an alternative to using VBA to build the interface, I have previously deployed Excel add-ins (XLAM files) using some variety of Ribbon XML. This allows for very fine-grained control of the resulting interface and does not require you to work in VBA to build the interface. For most applications, I have found it is much easier to build the Ribbon components outside of VBA and then wire up the callbacks in VBA.
For the end user, I think this approach also delivers a better looking add-in since the resulting interface has its own Ribbon tab (or you can add to any of the existing ones) instead of being in the Add-ins Ribbon tab.
If you want to pursue this route, I highly recommend using the Ribbon X Visual Designer to build the interface and set callbacks. I have used it to build an add-in that had more than 50+ features accessible by buttons and other Ribbon form controls. It was fairly painless once I got going.

Maximize form with DoCmd.maximize not working in access form

I have tried to maximize my access form with
DoCmd.Maximize
But when I double click, I can see the form not getting FULLY maximized for the ENTIRE screen.
The 'Tables-queries' pane on the left side is hiding the entire view.
I tried opening some of the sample access forms downloaded from web, they all opened in full screen . Some one please help me.
For Maximize to be effective you first have to change the Access option to allow Overlapping Windows. Then the form itself must be the active object. One way to activate the form is:
DoCmd.SelectObject acForm, "frmName"
You can minimize the Navigation Pane (on the left) with:
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Minimize
You can minimize the Ribbon with:
DoCmd.ShowToolbar "Ribbon", acToolbarNo
'to show it..
'DoCmd.ShowToolbar "Ribbon", acToolbarYes
The form will occupy the remaining space - the maximimum amount available to it. it won't occupy the ENTIRE screen.
(Below answer is not for regular behavior. When a form modal property is set to "yes" or true, you have to type one statement outside a form to solve your problem)
If you call a form using:
Docmd.openform "yourFormName"
Right after those statement type again:
Docmd.maximize
Enjoy!