473,545 Members | 1,288 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I Disable or Dim Sub-Menu Items Based on UserName

22 New Member
I have my own menu bar which i have created called "Angola LNG Incident Reporting". My intention was to dim or disable sub-menu items base on user name.

Following code i am using right now. It works just fine to dim but doesn't appears to be working base one user's name. Is there any thing wrong of doing this.
Expand|Select|Wrap|Line Numbers
  1. If Me.UserName.Value = "aman" Then
  2.     CommandBars("Angola LNG Incident Reporting").Controls(1).Controls(1).Enabled = False
  3.     CommandBars("Angola LNG Incident Reporting").Controls(1).Controls(2).Enabled = False
  4.     CommandBars("Angola LNG Incident Reporting").Controls(1).Controls(3).Enabled = False
  5. ElseIf Me.UserName.Value = "McAnthony" Then
  6.     CommandBars("Angola LNG Incident Reporting").Controls(1).Controls(1).Enabled = True
  7.     CommandBars("Angola LNG Incident Reporting").Controls(1).Controls(2).Enabled = True
  8.     CommandBars("Angola LNG Incident Reporting").Controls(1).Controls(3).Enabled = True
  9. End If
Appreciate if you help me out
Thanks,

** Edit **
This question was split away from How i can stop users running MDB file from another location?.
Oct 29 '11 #1
1 1903
NeoPa
32,563 Recognized Expert Moderator MVP
Assuming the criterion is simply that it matches the term "aman", and that your object reference is correct, then your code should look like :
Expand|Select|Wrap|Line Numbers
  1. Dim blnShow As Boolean
  2.  
  3. blnShow = Nz(StrComp(Me.UserName, "aman", vbTextCompare), True) = False
  4. With CommandBars("Angola LNG Incident Reporting").Controls(1)
  5.     .Controls(1).Enabled = blnShow
  6.     .Controls(2).Enabled = blnShow
  7.     .Controls(3).Enabled = blnShow
  8. End With
Oct 29 '11 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
11594
by: Patrick L. Nolan | last post by:
We have a Tkinter application which has a menubar with cascade submenus. I would like to start the program with one of the submenu items state=DISABLED, then change it to state=NORMAL at a later time. I hope I just missed something obvious, because I can't figure out how to change its state. The problem comes about because the menu bar is...
30
2457
by: Blnukem | last post by:
Hi All I'm new to javascript and was wondering if someone can help me with this I want to disable my second and third drop-box if the first one is selected to "Closed" I think I'm close but just cant get it to work here is my code: <html> <head>
0
1083
by: Hyrum Mortensen | last post by:
Hi, I have a CheckBoxList that's populated by a database (Selected property is set based on data from the database). I want to disable rows that have the Selected property set to true (i.e. once a row is Selected, disable the row so that it can't be de-Selected.). Is this possible? I can't find a suitable property under the ListItem...
3
2223
by: MervinJadhav | last post by:
How to disable combo items? Mervin Jadhav Software Developer Solutiioneyes Pvt Ltd (http://www.solutiioneyes.com) 203, Sai Chambers, 16 Mumbai-Pune Rd, Pune - 411 003 INDIA
1
1803
by: mkrei | last post by:
I have datagrid that I format at runtime with tablestyles and adding columns. I have a DataGridBoolColumn that I have subclassed, but can't get the right result. I want to disable a cell based on the initial value of that checkbox. If the initial value is checked, I want it to be disable where the user can't change it. If the intial value...
2
18434
by: ShaneO | last post by:
Probably a stupid question, but I can't seem to find how to Enable/Disable Submenu items within a MenuStrip. File -Open -Save .. ..
1
1294
by: C Wilson | last post by:
I may need to resort to some other tool but right now I'm limiting myself to XPath and XSLT and suchlike. I'm an XPath newbie. I'm framing my question as a structural one and what I think I'm looking for is a structural answer, not exact source code. I have a document that has several collections at the same level. The two that concern me are...
8
2312
by: metaphysics | last post by:
I'm not sure if this is possible, but I thought I saw it somewhere and I'd like to know how to do it. This is rather difficult to explain, so bare with me. Lets say you have 3 background colors, going from lightest to darkest (so color 1 would be the lightest and color 3 would be the darkest). I'll try to illustrate what I mean. Let's...
2
6252
by: Claudia Fong | last post by:
Hi, I added a tabcontrol in a panel in my form. My tabcontrol have more than 3 pages.. each page contains textboxes, combobox, checkbox. I want to disable the items of each of the page of the tabcontrol (so that the user won't be able to change the values in the textboxes, combobox, checkbox) without the tabcontrol turn into grey.
0
7651
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7410
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7746
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5962
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5320
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4941
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
693
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.