security (1 Viewer)

krishnanhemanth

Registered User.
Local time
Today, 19:54
Joined
Jun 12, 2009
Messages
115
hi all
i am able to retrive user using the function fosusername()
i have a lock button on all forms that by default locks the form on load and unlocks only if the lock button is clicked

what i want is

to enable or disable the lock form depending on the user that is logged in

please help

krishnanhemanth
 

evanscamman

Registered User.
Local time
Today, 07:24
Joined
Feb 25, 2007
Messages
274
I would create a table with all of your users and a checkbox for whether or not to allow acces for each user.

Then on form load, check the current user against the database to determine the state of the form - locked or unlocked.
 

krishnanhemanth

Registered User.
Local time
Today, 19:54
Joined
Jun 12, 2009
Messages
115
THANKS FOR THE IDEA

i have created a table with username and permission types

how am i suppose to call it in vba

please help
 

evanscamman

Registered User.
Local time
Today, 07:24
Joined
Feb 25, 2007
Messages
274
Code:
dim blnUnlock as boolean
 
blnUnlock = dlookup("[UnlockTrueOrFalse]","YourTable","[EmployeeName] = '" & strSystemUserName & "'")
 
myField1.Enabled = blnUnlock
myfield2.Enabled = blnUnlock

The dLookup command will retrieve a value from your table.
UnlockTrueOrFalse is the checkbox field in your table
EmployeeName is the field in your table that contains the TEXT name of employee
strSyltemUserName is the string you retrieved from the system containing your user's name.

blnUnlock will return True or False.
Then you can run your lock or unlock routine - I'd probably put it in it's own function, and then call it and pass the blnUnlock variable to it. Then it can be used to either lock or unlock your form.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:24
Joined
Feb 28, 2001
Messages
27,187
I do something like this. For bound forms, do this kind of VBA work in the form_current routine. For unbound forms, you might need to use either form_activate or form_load (depending on specifics of what you wanted to do.)
 

Users who are viewing this thread

Top Bottom