473,473 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Create 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 1896
NeoPa
32,556 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
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...
30
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...
0
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....
3
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
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...
2
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
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...
8
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...
2
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...
1
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...
0
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,...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
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...

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.