Enabling buttons on forms

G

Guest

The normal way of enabling a button so the user can click on it at the form
level is:

expression.enabled = true

eg. cmdMyButton.enabled = true

This makes the button active and not greyed out.

Say you wanted to add a bit of security to the buttons on the forms, and
only some are enabled and some are not, depending what user you log into the
system as. I'm having a problem where we store all the "cmd*" command
buttons in a table, and i can't seem to get the code to supply an value from
the table, into the expression.enabled = true to run. This would be easier
because we can manage who gets what access to what on the forms. So the main
question is, is there a way to pass in a value from a table, into the
expression?
 
S

Steve

The code to enable a button can also be written:
Me("NameOfButton").Enabled = True

You can use this syntax to do what you want to do ---
Dim ButtonName As String
ButtonName = "Text3"
Me(ButtonName).Enabled = True

You then need to change line 2 in the above code to get the button name from
your table.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
S

StopThisAdvertising

Steve said:
The code to enable a button can also be written:
Me("NameOfButton").Enabled = True

You can use this syntax to do what you want to do ---
Dim ButtonName As String
ButtonName = "Text3"
Me(ButtonName).Enabled = True

You then need to change line 2 in the above code to get the button name from
your table.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)

--
You are *not* a resource at all !!
Stop advertising here, or get lost for another year or so...
http://home.tiscali.nl/arracom/whoissteve.html

ArnoR
 
G

Guest

First you need a table that defines all the users and what their rights are.
Then you use the Load event of your form to:
Determine who the current user is.
Read the table to see what their rights are.
Enable or Disable controls depending on the user's rights.
Since there a number of ways to do this, I can't give a whole lot of detail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top