Disable/Remove "New Record" button when a Form is activated

I need to know how to remove the New Record button on the navigation bar at the bottom of a form (which is based on a table). Also, I would like to disable the New Record button on the toolbar when this form is activated. Thanks.


Comments

  • To remove the New Record button, turn Navigation off - set form property "Navigation Buttons" to "No" and then create your own Navigation system if required.

    As far as disabling the new record button on the toolbar, below is a sub that I use to do various things to the toolbar and the menu bar. I think you will be able to take from it what you need.

    It is written to work in Access 97 and requires setting a reference to "Microsoft Office 8.0 Object Library", filename "MSO97.DLL".

    The sub takes one parameter as input called "sTheState". If "Disable" is send into this sub, certain toolbars and menu items are turned off, otherwise, they are turned on.

    Hope this helps. Good luck!

    Tom

    '********CODE START*********

    Sub EnableDisableToolsAndMenu(sTheState)
    On Error GoTo Err_EnableDisableToolsAndMenu

    Dim CBarMenu As CommandBar
    Dim CBarMenu2 As CommandBar
    Dim CBarTool As CommandBar

    Dim sMyMenuBar As String
    Dim sMyMenu As String
    Dim sMyMenu2 As String
    Dim sMyMenu3 As String
    Dim sMyMenu4 As String
    Dim sMyMenu5 As String
    Dim sMyMenu6 As String
    Dim sMyMenu7 As String
    Dim sMyMenuCmd As String
    Dim sMyMenuCmd2 As String
    Dim sMyMenuCmd3 As String
    Dim sMyMenuCmd4 As String
    Dim sMyMenuCmd5 As String
    Dim sMyToolBar As String

    sMyMenuBar = "Menu Bar"
    sMyMenu = "Edit"
    sMyMenu2 = "Records"
    sMyMenu3 = "Tools"
    sMyMenu4 = "View"
    sMyMenu5 = "Insert"
    sMyMenu6 = "File"
    sMyMenu7 = "Window"
    sMyMenuCmd = "Find..."
    sMyMenuCmd2 = "Filter by Form"
    sMyMenuCmd3 = "Database Window"
    sMyMenuCmd4 = "New Object"
    sMyMenuCmd5 = "View"
    sMyToolBar = "Form View"

    Set CBarMenu = CommandBars(sMyMenuBar)
    Set CBarTool = CommandBars(sMyToolBar)

    If sTheState = "Disable" Then

    'Turn off Toolbar items
    CBarTool.Controls(sMyMenuCmd).Enabled = False
    CBarTool.Controls(sMyMenuCmd2).Enabled = False
    CBarTool.Controls(sMyMenuCmd3).Enabled = False
    CBarTool.Controls(sMyMenuCmd4).Enabled = False
    CBarTool.Controls(sMyMenuCmd5).Enabled = False

    'Turn off menu items
    CBarMenu.Controls(sMyMenu).Enabled = False
    CBarMenu.Controls(sMyMenu2).Enabled = False
    CBarMenu.Controls(sMyMenu3).Enabled = False
    CBarMenu.Controls(sMyMenu4).Enabled = False
    CBarMenu.Controls(sMyMenu5).Enabled = False
    CBarMenu.Controls(sMyMenu6).Enabled = False
    CBarMenu.Controls(sMyMenu7).Enabled = False

    Else 'Turn on the items

    'Turn on Toolbar items
    CBarTool.Controls(sMyMenuCmd).Enabled = True
    CBarTool.Controls(sMyMenuCmd2).Enabled = True
    CBarTool.Controls(sMyMenuCmd3).Enabled = True
    CBarTool.Controls(sMyMenuCmd4).Enabled = True
    CBarTool.Controls(sMyMenuCmd5).Enabled = True

    'Turn on menu items
    CBarMenu.Controls(sMyMenu).Enabled = True
    CBarMenu.Controls(sMyMenu2).Enabled = True
    CBarMenu.Controls(sMyMenu3).Enabled = True
    CBarMenu.Controls(sMyMenu4).Enabled = True
    CBarMenu.Controls(sMyMenu5).Enabled = True
    CBarMenu.Controls(sMyMenu6).Enabled = True
    CBarMenu.Controls(sMyMenu7).Enabled = True
    End If

    Set CBarTool = Nothing
    Set CBarMenu = Nothing

    Exit_EnableDisableToolsAndMenu:
    Exit Sub

    Err_EnableDisableToolsAndMenu:
    MsgBox Err.Description & " - Module = EnableDisableToolsAndMenu"
    Resume Exit_EnableDisableToolsAndMenu

    End Sub

    '********CODE END*********

    : I need to know how to remove the New Record button on the navigation bar at the bottom of a form (which is based on a table). Also, I would like to disable the New Record button on the toolbar when this form is activated. Thanks.
    :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion