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

Hide Command button and form from group of users

42
Created a database that I want to be maintained and updated by the Department designated Admins. I have an user table that set specific individuals access to Admin and created admin form and functions to add data to tables and new users when needed. However, I only want the admins to see the command button on the form to access the Admin form menu. I have been unable to acheive this.
Mar 29 '10 #1

✓ answered by ADezii

Assuming [Admin] is a Yes/No Data Type Field:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![Command13].Visible = DLookUp("[Admin]", "tbl_racifid")
  3. End Sub
Assuming [Admin] is a Text Data Type Field:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![Command13].Visible = (DLookUp("[Admin]", "tbl_racifid") = "Yes")
  3. End Sub

7 7185
ADezii
8,834 Expert 8TB
Assuming that your Command Button is named Command1, in the Current() Event of your Form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![Command1].Visible = (CurrentUser = "Admin")
  3. End Sub
Mar 29 '10 #2
Bre035
42
doesn't work. My form is frm_Admin and the command button is Command13. My table that identifies the Admins is tbl_racifid and the field is Admin set to Yes. I have tried Me.Visible statement.
Mar 29 '10 #3
ADezii
8,834 Expert 8TB
Assuming [Admin] is a Yes/No Data Type Field:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![Command13].Visible = DLookUp("[Admin]", "tbl_racifid")
  3. End Sub
Assuming [Admin] is a Text Data Type Field:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   Me![Command13].Visible = (DLookUp("[Admin]", "tbl_racifid") = "Yes")
  3. End Sub
Mar 29 '10 #4
Bre035
42
I changed the field type to yes/no and tweek the code a little to read:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.  
  3.   If DLookup("admin", "tbl_racfid", "[Racf_ID] = """ & Form_frm_login.Login_RacfID.Value & """") = True Then
  4.    Me.btn_admin.Visible = True
  5.   Else
  6.    Me.btn_admin.Visible = False
  7.   End If
Mar 29 '10 #5
NeoPa
32,556 Expert Mod 16PB
@ADezii
It's so good to see coders who can handle boolean evaluations properly. So many use the form :
Expand|Select|Wrap|Line Numbers
  1. If X = Y Then
  2.  Z = True
  3. Else
  4.   Z = False
  5. End If
instead of the more sensible :
Expand|Select|Wrap|Line Numbers
  1. Z = (X = Y)
The latter (your code) is so much more succinct and to the point, and shows an understanding of what you're dealing with.
Mar 29 '10 #6
hedges98
109 100+
Thanks for that comment NeoPa, I realised I have been using the 'less sensible' code for boolean expressions so have gone through my code and altered some of them so it's tidier!
Mar 30 '10 #7
NeoPa
32,556 Expert Mod 16PB
Most people do. There's no shame in starting that way. It's just that when someone (ADezii in this case) shows the way I like to highlight why it's better so people notice and get the point. I'm very pleased to see that you have :)
Mar 30 '10 #8

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

Similar topics

13
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is...
3
by: Harry | last post by:
I want to provide a drill down facility for the users - the plan is to intially display a table with summary rows containing results of previous selected search criteria. In each summary row you...
2
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow {...
4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
4
by: MJW | last post by:
Is there a way for me to know if or which command button was just clicked that triggers the LostFocus event for the current control on a Form? I have a form that has many types of users who each...
2
by: Mark | last post by:
Hi all, I have a pop-up which has several command buttons which allow users to run a few stored query's. Having the query's displayed as report is not an option due to several reasons. My problem...
1
by: Glarb Shattenstein | last post by:
I am posting data to one form (integers mostly) with variables dimensioned at the modular level (i.e. mdecTotal as Integer) and have calculations performed on those variables in another form. The...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
0
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
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...

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.