Changing forms based on permissions

  • Thread starter Thread starter Vivian Carroll
  • Start date Start date
V

Vivian Carroll

In Access 2000, I have written code for my main data entry form that checks
to see whether the user belongs to the Engineers group and if so, then
disables the AddRecord button (and some others). However, in the future, I
might add other groups that also should be blocked from adding, so I think
it would be better to say:

If the user does not have permission to Update Data in the Drawings table,
then disable the AddRecord button.

Can anyone help me with the code for "if the user does not have permission
to Update Data in the Drawings table"?

TIA,
Vivian Carroll
 
I generally do this sort of thing by keeping a globally visible set of
permission flags for the current user and initialising the flags
either on application startup or when the user logs in (where I have
specific login code in the application). You can then check the user's
privileges quickly and easily anywhere in the application.
 
Thank you for answering Peter. However, I am not as advanced as you and do
not know how to do what you suggested. Can you direct me to somewhere that I
can read how to do this?

Peter R. Fletcher said:
I generally do this sort of thing by keeping a globally visible set of
permission flags for the current user and initialising the flags
either on application startup or when the user logs in (where I have
specific login code in the application). You can then check the user's
privileges quickly and easily anywhere in the application.





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Quite!


I believe what Peter is suggesting is that you create a regular module (in
the database window, select modules, then select new), and in the
declarations section of that module, put some "global" variables that can be
access from any of your database's procedures:

Public blnUserAllowedToAdd As Boolean

etc.

Then you can use code in your forms, etc. to set the value of this public
variable and to test its value.
 
Vivian

To put you out of your misery, you need something like this. (Untested, as I
don't havce Access here to check - but it's on the right track.)

dim db as database, td as tabledef, perms as long
set db = currentdb()
set td = db.tabledefs![Drawings]
td.username = currentuser() ' probably not required.
perms = td.allpermissions ' user & group permissions.
if (perms and acupdatedata) = acupdatedata then
' current user can update data in the Drawings table.
endif

HTH,
TC


Peter R. Fletcher said:
Quite!






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top