control locking

arage

Registered User.
Local time
Today, 20:24
Joined
Dec 30, 2000
Messages
537
in my form I’ve managed to lock a group of fields based on their tag property. But since some of these controls need to be unlocked (based on the user) I’m having difficulty working around that. What property could I use other than the tag property to go back & open a few of them.

I’d written a lockTax function that would lock all the controls with “tagTax” property but now need to unlock a few of them. there are 4 controls & not all of them are used, based upon the user.

I’d written another unlockTax function then that used a for loop for the controls with the “tagTax” property, and then based on a case that tells which user it is, I couldn’t come up with adequate criteria to do my unlocking. I have about 4 users and each one only uses 1 to 2 of the 4 controls at a time.
 
I had this situation and I used portions of the tag property to determine which to lock and unlock. Say I have a group of users Information Systems Department ("ISD") and within that group some developers ("DEV").

Now I want to lock all IS people out of some of the controls, but I want my developers to have access to a couple of those controls.

So basically, my tags consist of groups of codes. Like "ISDXXX", and "ISDDEV".

So for locking out IS I use
for each ctl in me.forms
if left(Ctl.tag,3)="ISD" then
ctl.locked=true
end if
next ctl

THEN I unlock the two controls if the user is a developer.

for each ctl in me.forms
if right(Ctl.tag,3)="DEV" then
ctl.locked=false
end if
next ctl

make sense? Is this kind of what you're looking for? let me know!
 
well Charity i'm trying something else right now in case of future I need to lock something else, so rather than hard coding 4 control names I wrote function to lock any control I pass as a parameter.

Here’s the current event of the form:

Private Sub Form_Current()

'determine the region...
Dim x As Variant
x = GlobalRegionCode
x = Mid(x, 2, 1)

'lock taxes based on region...
If x = 5 Then
Call lockControl(Me.ForecastHST)
Call lockControl(Me.ForecastQST)
End If

End Sub

And here is the function meant to lock any control:

'lock a control...
Private Sub lockControl(controlName As control)
controlName.Enabled = False
controlName.Locked = True
End Sub

Problem though is that when lockControl is called, controlName contains a 0! It doesn’t contain the control names I passed in the current event of the form even though I made sure that x=5! What’s up?
 
Hi Arage,

Have you tried to use the complete syntax to reference your Ctl, instead of Me?

Forms!FormName!ControlName

or for a control in a subform:
Forms!MainFormName!SubformName.Form!ControlName

Alex
 

Users who are viewing this thread

Back
Top Bottom