You should be able to use a Dlookup (or ELookup) and an if/then condition.
Something like this.
If IsNull(ELookup("Userfield", "adminstable", _
"[Userfield] = """ & YourNTUsername & """")) Then
Me.controltohide.visible = False
'or
Me.ControlToHide.Enabled = False
End If
What you may also want to do is put something in the controls Tag, like
"AdminControl", and loop the controls of the form:
(aircode)
Dim ctl As Control
If Not IsNull(ELookup........) Then
For Each ctl In Me
If ctl.Tag = "AdminControl" Then
ctl.Enabled = True
End If
Next
End If
Set ctl = Nothing
you may need some code in there to verify that it has a Tag property, I'm
not sure that all controls do, but this would be handy if you have a number
of controls.
hth
--
Jack Leach
www.tristatemachine.com
"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
"Steve in MN" wrote:
> I want to put a check box on a form but only want that check box (and label)
> to be visible to certain people because it is a finalization of a process.
>
> So I have the Module for current user set up in the DB.
>
> In the On_Load property of the form, I want to have the code check the
> "current User" against a list of "Users" from table "Admin_Users" and if the
> current user (from NT login) equals one of the "Users" from the "Admin_Users"
> table then that check box and label would be visible. If the current user is
> not on the list, then the check box and label would not be visilble.
>
> I know this has to do with loops and I have not had any experience yet on
> setting them up.
>
> I know this is probably pretty easy and as soon as I see it I will click,
> but I can't figure it out.
>
>
> Thanks