Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1174
Number of posts: 2221

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Disable/Remove "New Record" button when a Form is activated Posted by diensatthan on 28 Apr 2003 at 8:32 PM
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.


Report
Re: Disable/Remove "New Record" button when a Form is activated Posted by wiegelman on 23 May 2003 at 9:24 AM
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.
:
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.