• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

How do I check windows username against table of accepted users?

I know how to extract the windows username using environ("USERNAME").

I would now like to validate the username against a list af accepted users (tbl_Users).

How can that be done?
0
LarsDyrby
Asked:
LarsDyrby
  • 3
  • 2
1 Solution
 
mbizupCommented:
Try this:

Dim sUser as string
sUser =  environ("USERNAME"). 
IF DCount("*", "tbl_Users","UserName = '" & sUser & "'")  > 0 then
       msgbox "Validated!"
Else
      msgbox "Not validated!"
end if 

Open in new window

0
 
mbizupCommented:
That said, this is generally a better option for Windows Usernames than the Environ function:
http://access.mvps.org/access/api/api0008.htm
0
 
Anthony BerenguelCommented:
There are a few different ways of doing this. What are the fields in tbl_Users? Are all users in that table or only accepted ones?
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
LarsDyrbyAuthor Commented:
tbl_Users contains only the accepted users
0
 
mbizupCommented:
The code I posted should do the trick.

It uses "UserName" as the field where your usernames are stored.  You'll have to substitute that with whatever fieldname your database actually uses.  eg: if your field name is "SignOn", you'd revise the DCount to reflect that:

IF DCount("*", "tbl_Users","SignOn = '" & sUser & "'")  > 0 then
0
 
LarsDyrbyAuthor Commented:
Thx to mbizup
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now