473,382 Members | 1,357 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,382 software developers and data experts.

Disabling and Enabling Form buttons

33
I have a table with a field called DEPT_ACCESS. I also have a form called FRMACCESS with 3 buttons called DEPT_1, DEPT_2 and DEPT_3. I want to write a code such that when a user from whose DEPT_ACCESS is 1 opens the FRMACCESS, only the button called DEPT_1 should be enabled. Similarly, user whose DEPT_ACCESS is 2 should have only button called DEPT_2 enabled. The same criterion holds for user with DEPT_ACCESS 3. The name of the table is called TBLADMIN.
Aug 4 '08 #1
3 1412
If you have implemented Microsoft Access Security then you can get the name of the Form's current user name with the Function CurrentUser. But you must be able to identify a particular user with the department and accordingly you can enable or disable Buttons.
Expand|Select|Wrap|Line Numbers
  1. if currentuser = "xyz" and [Deptt]="DEPART_1" then
  2.    me![DEPART_1].enabled = true
  3. end if
try the following link for Microsoft Access Security implementation
http://www.msaccesstips.com/2006/11/...security.shtml
Aug 4 '08 #2
NeoPa
32,556 Expert Mod 16PB
How does the code know which department the user is in?

I assume TBLADMIN must enable you to translate a user name into a department (although you don't say so in the question), but how do you propose to determine who the user is in the first place? It's possible of course, but the problem is there are a number of ways it COULD be done. How are YOU planning to do it?
Aug 10 '08 #3
Annalyzer
122 100+
Here's a function I found when I needed to know which user was currently logged in.

Expand|Select|Wrap|Line Numbers
  1. Public Function CNames(UserOrComputer As Byte) As String
  2.     'UserorComputer; 1=User, anything else = computer
  3.     Dim NBuffer As String
  4.     Dim Buffsize As Long
  5.     Dim wOK As Long
  6.  
  7.     Buffsize = 256
  8.     NBuffer = Space$(Buffsize)
  9.  
  10.     If UserOrComputer = 1 Then
  11.         wOK = api_GetUserName(NBuffer, Buffsize)
  12.          CNames = Trim$(NBuffer)
  13.     Else
  14.         wOK = api_GetComputerName(NBuffer, Buffsize)
  15.         CNames = Trim$(NBuffer)
  16.     End If
  17. End Function
It's working great for me. I hope you find it useful as well. Wish I could give credit where credit was due, but I can't remember where I found this.
Aug 10 '08 #4

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

Similar topics

13
by: Howard Kaikow | last post by:
How does one enable/disable JavaScript in IE 6? -- http://www.standards.com/; See Howard Kaikow's web site.
6
by: Leonard | last post by:
I have several radio buttons for the user to choose from. I need to enable or disable a particular radio button, depending on a certain condition. How can I do this? Thanks, Leonard
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
2
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have...
1
by: Lamine Darbouche | last post by:
Please Help, I have a form with multiple buttons "New User", "Delete User", "Save" buttons, when I access the form it selects the "New User" button by default, so when you hit the return key...
7
by: John Meyer | last post by:
I have a program where I have to enable or disable a list box based upon a radio button. Is there an "enabled" property on select boxes?
2
by: dougawells | last post by:
Hi- I'm wanting to have a set of radio buttons disabled when a form is displayed, then if they check another specific radio button, those would become enabled. I've tried setting it via...
1
by: hello2008 | last post by:
Hi, I have just started coding in PHP. I have coded a web page using HTML, JS, and PHP. An HTML table has to be populated dynamically using the data from the backend. Presently I have 5...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.