By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Public Locking VBA

P: 3
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.

Share this Question
Share on Google+
2 Replies


NeoPa
Expert Mod 15k+
P: 31,419
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
Expert 100+
P: 1,107
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

Post your reply

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