Or you could disable the command buttons based on the users permissions.
Many of my recent applications have had multiple network users with a
variety of different roles. So what I generally do is create a Roles table,
with the specific roles I want to assign users to, and then a User_Roles
table to actually assign users to a role.
Then, when my Splash form loads, I call a bunch of functions
Call fnAdmin(Reset:=True)
Call fnHR(Reset:=True)
similar to the one below which read the User_Roles table and determine
whether the currentuser is assigned to that role.
Public function fnAdmin(Optional SomeValue as Variant = Null, _
Optional Reset as Boolean = false)
Static myAdmin as Variant
Dim strUserID as String
Dim strCriteria as string
if Reset = True or isEmpty(myAdmin) then
strUserID = fOSUsername()
strCriteria = "[User_ID] = """ & strUserID & """ AND " _
& "[User_Role] = 'Admin'"
myAdmin = iIf(DCOUNT("ID", "tbl_User_Roles", strCriteria) = 0, False,
True)
elseif isnull(SomeValue) = False then
'use this to set the value manually for testing purposes
myAdmin = SomeValue
Endif
fnAdmin = myAdmin
End Function
Finally, when I load my forms I will use those functions to determine what
controls I want to be visible, or enabled. In your case, you could either
disable/hide the command button based on whether the individual should have
access to the specific form.
You might even want to use the forms current event to lock or unlock
specific controls based on the user roles.