>That is the sort of thing I'm looking for, but unfortunately I haven't go SDT, could you think of another way, the only thing I can think of is having a table to hold the table.field names and have each userlevel beside that saying whether it's readonly or not. But this will surely slow the applications refresh down!!
>
>Kev
I use SDT to make controls enabled/disabled based on an SDT property for that specific field. That was an example for application specific access to a field. The other was an example of user level.
For user level, you will need to define for each user what access they have. The simplest is to have 3 levels -- Admin [access to everything], Editor [edit most or all fields], ReadOnly [data retrieval only]. Identify each user with one of these 3 types. In the REFRESH of your control baseclasses, you would check wht the current user is and disable or enable the controls accordingly. You will see no perceptible performance hit for this.
You can go the other extreme, and create a UserAccess table with a structure like:
KeyID
UserID
TableName
FieldName
ReadOnly
In the Refresh of each control, I would call a method in my global application object like --
procedure refresh && in the baseclass of each control
llEnabled = goAPP.GetUserRights(This.ControlSource)
This.Enabled = llEnabled
endproc
Calling something like the following code should not perceptibly affect performance either.
procedure GetUserRights
lparameter tcSource
if vartype(tcSource) <> "C"
return [whatever you want .t. or .f.]
endif
if empty(tcSource)
return [whatever you want .t. or .f.]
endif
local lcTable, lcField, lnSelect
lcTable = juststem(tcSource)
lcField = justext(tcSource)
if empty(lcTable)
return [whatever you want .t. or .f.]
endif
if empty(lcField)
return [whatever you want .t. or .f.]
endif
lnSelect = select()
if !used("UserAccess")
use UserAccess in 0
endif
select UserAccess
set order to UserID
seek goApp.nUserID
if eof()
return .f.
endif
locate for TableName = lcTable while UserID = goApp.nUserID
if eof()
return .f.
endif
locate for FieldName = lcField while TableName = lcTable
if eof()
return .f.
endif
select (lnSelect)
return UserAccess.ReadOnly
endproc
Mark McCasland
Midlothian, TX USA