473,406 Members | 2,345 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,406 software developers and data experts.

How to disable and enable the secondary menu bar if the user is false

All,

I have db which contained user login system which mean i have form that opens when i open db. Also i have created my own menu bar. What i am looking for is how to disable menu bar that i have created if the the user logged invalid and enable if the user valid

in other words, i don't want user to open any other forms from the menu bar if the users click on the menu bar items without login

Any prompt help appreciated
Thanks,
Jul 16 '11 #1
8 2632
ADezii
8,834 Expert 8TB
Here is the Semi-Suedo Code (just made that up) given a Custom Menu Bar named Custom Menu:
Expand|Select|Wrap|Line Numbers
  1. Dim blnValidLogin As Boolean
  2.  
  3. 'blnValidLogin will return either True or False
  4. 'blnValidLogin = (Username & Password are an exact Match)
  5.  
  6. 'Show/do not Show based on Current Value of blnValidLogin
  7. If blnValidLogin Then
  8.   DoCmd.ShowToolbar "Custom Menu", acToolbarYes
  9. Else
  10.   DoCmd.ShowToolbar "Custom Menu", acToolbarNo
  11. End If
Expand|Select|Wrap|Line Numbers
  1. Dim blnValidLogin As Boolean
  2.  
  3. 'blnValidLogin will return either True or False
  4. 'blnValidLogin = (Username & Password are an exact Match)
  5.  
  6. blnValidLogin = False
  7.  
  8. Application.CommandBars("Relationship").Enabled = blnValidLogin
Jul 16 '11 #2
Dezii,
Thanks for your help. It did not work. I think something wrong with me as i am new on VBA. As i run that code i got runtime error 2094 (Can't find the tool barbar "Custom Menu")
Dezi, may be i could not explained enought of need.
Here is another example of my needs:
1) I have form called user login where users need to login first with their valid user name & password.
2)I have Created own menu bar where user can see the different options with drop down list.
3)I have removed the default and added my menu bar as a start up.

Now i want VBA code to disable & enable of menu bar if the user use invalid user name and password

If user is valid then Menu bar enable
else
Menu bar disable

I know, you can help me out.

Thanks,
Jul 18 '11 #3
Adam Tippelt
137 100+
I imagine you got that error because ADezii was using 'Custom Menu' as the variable name which you should have replaced with the name of your own menu. As he said it iss semi-suedo it wouldn't just run as is.

Is your login form separate to the 'main menu' form, or are they the same form with the menu hidden until valid login?

I have a setup whereby I use a login form which then closes and opens the main menu. I use the following code for login validation:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Login_Click()
  2.  
  3. 'Check if the username field is empty.
  4. If IsNull(Me.Username) Or Me.Username = "" Then
  5.     MsgBox "You must enter a Username.", vbOKOnly
  6.     Me.Username.SetFocus
  7.     Exit Sub
  8. End If
  9.  
  10. 'Check if the password field is empty.
  11. If IsNull(Me.Password) Or Me.Password = "" Then
  12.     MsgBox "You must enter a Password.", vbOKOnly
  13.     Me.Password.SetFocus
  14.     Exit Sub
  15. End If
  16.  
  17. 'Confirm if the password is correct for the username entered.
  18. If Me.Password = DLookup("Password", "tblUsers", "[UserName]= '" & Replace(Me.Username, "'", "''") & "'") Then
  19.     DoCmd.Close acForm, "Login Page"
  20.     DoCmd.OpenForm "Main Menu"
  21. Else
  22.     MsgBox "Incorrect username or password. Please try again.", vbOKOnly + vbCritical, "Access Denied."
  23.     Me.Username.SetFocus
  24. End If
  25.  
  26. End Sub
This works on the assumption that you have a table which stores your User details.
Note that this code includes the variable names that I use in my own code - these are the things which you should replace with the names of variables in YOUR code:

Login_Click = Login is the name of the button clicked to initiate this procedure. (The _Click suffix is not part of the name, it's just to make it clearer what I'm referring to)
(Likewise, the Me. prefix is not part of the name, it's just to make it clearer what I'm referring to)
Me.Username = Username field on the login form.
Me.Password = Password field on the login form.
tblUsers = The name of the table which stores the user details.
Password = Name of the Password column in the user table.
UserName = Name of the username column in the user table.
Main Menu = Name of my menu form.

Hope that helps.

Adam.
Jul 18 '11 #4
Adam,
Thanks for reply. I have the same code alreay in used and it is working fine as intended but i was looking for something else where i can use vba to disable and enable the secondary menu base on valid and invalid user login. I certain that you can help me on this. I am give you screen print to easy understanding of my needs.

I am using my own menu bar called "Incident Reporting" from Tool-Start Up and menu bar. note: I am not using access orginal menu bar and also added form called "UserF" which is user login form as start up when db opens. When i open my db the "userF" which user login form will appear first with my menu bar. But there is still access to jump to menu bar without login. I don;t user directly jump to menu bar and interact with other forms. I want user to first logged in and then able to use menu bar for menu items. if not menu should be disable

Thanks,
Jul 18 '11 #5
Adam Tippelt
137 100+
Are you talking about users being able to use the Navigation Pane to access other forms?

If this is the case, go to:

File (Office Button) -> Access Options -> Current Database -> Navigation

and untick the Display Navigation Pane option. You will need to restart the application for it to take effect, but it will mean the only way to gain access to the menu is by logging in.

This is an option that I normally leave enabled on a prototype copy, as you need it during development, but is something you should disable when handed over for actual use by users.


If this is not what you mean, please elaborate on how exactly user's are jumping to the menu bar without logging in.

Adam.
Jul 18 '11 #6
Adam, I will try this by using but i am using 2003 and there is no option as said. should be another way on 2003.

Its little comlicated but i should be able to get help of my needs soon.

Thanks a lot for your help.
Jul 18 '11 #7
Adam Tippelt
137 100+
Ah right, I was under the assumption that it was 2007.
I do not know 2003 very well, but I imagine the options exist somewhere on 2003 to disable whatever 2003's equivalent is of the navigation pane.
Try looking under Tools -> Options or similar areas, or perhaps someone with knowledge of 2003 can step in.
Jul 18 '11 #8
Adam,

End of the day i have fixed it.

Thanks a lot for helo & information shared with me.

Good day!
Jul 18 '11 #9

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

Similar topics

3
by: Richard Cleaveland | last post by:
I want to dim (disable) a specific menu item dropped down from a toolbar menu item. I looked for a property I could change but no luck. Access 97. Suggestions?
8
by: Ken Yu | last post by:
Hi, How can i disable "RightClick Menu" in Internet Explorer, when access the frontpage ? tks a lot ! Ken
7
by: Michael | last post by:
I'm exploring how to programmatically disable/enable devices in a system using C#. -MH
1
by: John Devlon | last post by:
Hi, Can someone please help me. I've got a strang problem in Visual Studio 2005 I've created a windows application, using an MDI form and top menu. When a menu item is clicked, a new instance...
3
by: Pietro | last post by:
Hi all, First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm...
6
by: sergiockgoh82 | last post by:
Recently my task is developing a program to keep track the user logon. User after successed login on from the Windows logon, he will come to this program to provide login details on the 2nd...
0
by: Alexander Vasilevsky | last post by:
Can to disable/enable smoothing font in the WPF? http://www.alvas.net - Audio tools for C# and VB.Net developers
56
by: Deepan HTML | last post by:
Hi All, Currently i am working in a framed environment where i have divided the window as 20% and 80% and the 20% is used for navigation purpose and right frame for displaying the orignal content....
10
by: viki1967 | last post by:
Disable/enable icon.gif Hi all. I have this form in the page.htm: <form action="form.asp" method="post" onsubmit="return(validateForm(this));"> <select size="1" name="t_im"...
1
AR Ratheesh
by: AR Ratheesh | last post by:
Hi, Please help me to disable / enable task manager and Explore for a internet Cafe management project. Thanks in advance..
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
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,...

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.