Tags & Control Variables

jstutz

Registered User.
Local time
Today, 14:59
Joined
Jan 28, 2000
Messages
80
I have a db that has multiple levels of users from supervisors, down to data entry people. On some of the common forms, I would like to lock certain fields from being editted based on the user's security. I've put tags on these fields and am running the following code when the form opens to lock/unlock the fields:

For Each ctl In Screen.ActiveForm
If ctl.Tag = "EngSup" Then
ctl.Visible = True
End If
Next

Is it possible to also control the .Enabled, .SpecialEffect and .Backcolor properties of the control variable CTL like you control the .Visible property? I can't seem to figure it out. I think it SHOULD look like:

For Each ctl In Screen.ActiveForm
If ctl.Tag = "EngSup" Then
ctl.Enabled = True
ctl.SpecialEffect = 2
ctl.BackColor = 16777215
End If
Next
BUT, this doesn't seem to work. Any thoughts? I can make this work by hard coding the object names in my code thereby avoiding the use of Tags and the control vari, but I thought this code was neater.

Thanks!
js

[This message has been edited by jstutz (edited 09-17-2001).]
 
This is what I usually use. I would think that you could add other properties as needed:

Set frmMyForm = Forms!fMyLovelyForm

For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "Coord_btn" Then
ctlMyCtls.Visible = True
ctlMyCtls.Enabled = True
End If
Next ctlMyCtls
 
Thanks Chris! I think I must have had a typo somewhere b/c I was able to do something similar on a different form. I guess I was having a moment b/c I just couldn't see the typo.
frown.gif


Thanks again for your comments.

js
 

Users who are viewing this thread

Back
Top Bottom