PC Review


Reply
Thread Tools Rate Thread

validate current user to table of approved users

 
 
Steve in MN
Guest
Posts: n/a
 
      15th Sep 2009
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
 
Reply With Quote
 
 
 
 
Stuart McCall
Guest
Posts: n/a
 
      15th Sep 2009
"Steve in MN" <(E-Mail Removed)> wrote in message
news:B82CDEFB-DA3C-41F6-AE21-(E-Mail Removed)...
>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


No loops required here. The Dcount function will do the job for you.

Label.Visible = Dcount("*", "Admin_Users", "User='" & current_user & "'" > 0
checkbox.Visible = Label.Visible



 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      15th Sep 2009
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

 
Reply With Quote
 
Stuart McCall
Guest
Posts: n/a
 
      15th Sep 2009

"Stuart McCall" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Steve in MN" <(E-Mail Removed)> wrote in message
> news:B82CDEFB-DA3C-41F6-AE21-(E-Mail Removed)...
>>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

>
> No loops required here. The Dcount function will do the job for you.
>
> Label.Visible = Dcount("*", "Admin_Users", "User='" & current_user & "'" >
> 0
> checkbox.Visible = Label.Visible


Oops. Slight correction:

Label.Visible = Dcount("*", "Admin_Users", "User='" & current_user & "'") >
0
checkbox.Visible = Label.Visible

(I missed the terminating paren for the dcount function call)


 
Reply With Quote
 
Steve in MN
Guest
Posts: n/a
 
      16th Sep 2009
Thanks to both of you for the help, I will give them a try.

Steve

"Stuart McCall" wrote:

>
> "Stuart McCall" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > "Steve in MN" <(E-Mail Removed)> wrote in message
> > news:B82CDEFB-DA3C-41F6-AE21-(E-Mail Removed)...
> >>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

> >
> > No loops required here. The Dcount function will do the job for you.
> >
> > Label.Visible = Dcount("*", "Admin_Users", "User='" & current_user & "'" >
> > 0
> > checkbox.Visible = Label.Visible

>
> Oops. Slight correction:
>
> Label.Visible = Dcount("*", "Admin_Users", "User='" & current_user & "'") >
> 0
> checkbox.Visible = Label.Visible
>
> (I missed the terminating paren for the dcount function call)
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing for All Users or Current User JamesJ Windows Vista General Discussion 2 4th Jul 2009 04:47 PM
User.IsInRole -> I do not want current user but all users Peter Bons Microsoft ASP .NET 1 31st Mar 2006 11:31 AM
Check the user is a member of a domain users or current system users Venkat Microsoft C# .NET 0 20th May 2005 05:19 PM
How to access current user key of other users? Klaus Kassner Windows XP Basics 1 23rd Apr 2004 12:22 PM
Start Menu - All Programs - All users/Current user (Default user) Gary Windows XP Security 2 11th Aug 2003 07:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:53 AM.