473,394 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Public Locking VBA

So I want to create a public sub that locks the toolbar and shortcut menu based on the useraccess. How do i write this as a public sub? I want it to be on the form load of every form opened.

Here is the private version:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     If Globals.UserAccess("Toolbar") = True Then
  4.     DoCmd.ShowToolbar "Ribbon", acToolbarYes
  5.     Me.ShortcutMenu = True
  6.     Else: DoCmd.ShowToolbar "Ribbon", acToolbarNo
  7.     Me.ShortcutMenu = False
  8. End Sub
And the global user access pulls from the login screen of credentials. Thank you!
May 25 '17 #1

✓ answered by jforbes

To convert a Private Function to Public Function:
  • Create a Module to store the Public Function, make sure the name of the Module is unique and not the same as the Public Function or it wont compile
  • Make sure to put "Option Explicit" at the Top of the Module
  • Paste the Private Function into the Module, and replace the Private Declaration with the Public One.

2 932
NeoPa
32,556 Expert Mod 16PB
You ask about locking a toolbar yet your code seems to show and/or hide the toolbar.

Also, your code isn't working code as it has no End If so couldn't possibly run. Please don't ever post code for people to work with that doesn't even compile. There are threads that explain some of these basics in the forum at the top and left permanently visible.

We can probably help if the question's clear and unambiguous, but we do expect some effort on your part to avoid wasting time unnecessarily.
May 26 '17 #2
jforbes
1,107 Expert 1GB
To convert a Private Function to Public Function:
  • Create a Module to store the Public Function, make sure the name of the Module is unique and not the same as the Public Function or it wont compile
  • Make sure to put "Option Explicit" at the Top of the Module
  • Paste the Private Function into the Module, and replace the Private Declaration with the Public One.
May 26 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Vinay Aggarwal | last post by:
I have been thinking about the lazy initialization and double checked locking problem. This problem is explain in detail here http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html...
3
by: Wolfgang Bachmann | last post by:
We migrated a database from Version 5.1 to 8.1 and are experiencing massive locking problems. We migrated in the following steps: 0) Server 5.2, Clients 5.2: everithing was fine 1) Server 5.2,...
6
by: MS | last post by:
Access 97 here. I want a simple way to "lock" certain records on a form. Some records remain "live" until all data is available which happens over time. When all the fields are complete, I want...
3
by: Morten Wennevik | last post by:
Hi, I have a MDIChild with static properties that can be updated at any time by the MDIParent. These properties may also at unknown times be accessed by one or more worker threads. Now, I'm...
10
by: McFly Racing | last post by:
Thread Locking In Static Methods I have the need for a Log Manger class that has static methods. Normally I would use the lock statement or a Monitor statement both of which take a...
2
by: Tommy Martin | last post by:
I have a credit card page on my asp.net site and i want to make sure it only runs on a secure connection. Is there a way to make a page not run or to redirect it to the secure connection? Thanks...
16
by: akantrowitz | last post by:
In csharp, what is the correct locking around reading and writing into a hashtable. Note that the reader is not looping through the keys, simply reading an item out with a specific key: If i...
4
by: darrel | last post by:
I've been dealing with a file locking issue for a while. Our CMS spits out a new XML file each time an item in the DB is updated. This XML file is basically our site menu, and is what we use on...
10
by: Ami | last post by:
Hello everyone, I have developed a small access application and now I need to lock my forms against unwanted edits. I have used the code by Allen Browne I found here...
0
by: xpding | last post by:
Hello, I have a class MyEmbededList contains a generic dictionary, the value field is actually the MyEmbededList type as well. There is another class need to access and manipulate a list of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.