Eric,
My proposed method allows you to do whatever you would do with the custom
"security" you had in mind. The way to do what you are asking is to hide the
database window, so users can't access objects directly, and use, for
example, command buttons on forms to handle the objects (or switchboard(s),
the concept is the same). Then you can embed code in your command buttons
that will or will not allow users to carry out the action depending on the
user login name, or you can even show/hide or enable/disable command buttons
based on user login name, through some code in the On Open event of the form
the command buttons sit in. In either case, you could hardcode the user
names (not a very good idea in terms of maintenance) or you could store that
information in tables, which is a lot easier to maintain. For instance, you
could have a table with the user login name (PK) and a yes/no field for each
form, report etc. you want to control access to. I would suggest you do not
provide direct access to tables at all, just through forms.
An example of the first option (check security after command button is
clicked), to open a form:
Private Sub Command1_Click()
Dim vAllow as Boolean
vAllow = DLookup("[fldForm1]","tblSecurity","[fldUser]='" &
Environ("UserName") & "'")
If vAllow = False Then
MsgBox "Sorry, action not allowed", vbCritical, "Security Problem"
Exit Sub
End If
DoCmd.OpenForm ....'etc
....
End Sub
An example of the second option (disable button on form open):
Private Sub Form_Open()
Dim vAllow as Boolean
vAllow = DLookup("[fldForm1]","tblSecurity","[fldUser]='" &
Environ("UserName") & "'")
If vAllow = False Then
Me.CmdForm1.Enabled = False
End If
End Sub
(assumes all command buttons enabled by default)
HTH,
Nikos
Eric said:
Are you able to restrict usage to certain forms and the ability to edit
data in certain tables using this method? If so, is there some property that
has to be set on the tables or forms?