Check if UserName is in UserID field in table

Aubrey

Registered User.
Local time
Today, 00:32
Joined
Mar 20, 2009
Messages
18
Hi all,

I have created a database that keeps track of students whereabouts during half term, end of term holidays etc. There are five house in the college but I am only making it for one house at the moment...subsequently there are students who whouldnt be allowed to access the system.

I was wondering if anyone could give me some vba code that will enable me to check if the currently logged in user is in the students table or not and then allocate different permissions depending on the answer.

As usual I expect that this is relatively simple...just not for me!!

If you need any further information then just ask

Cheers

James Aubrey
 
Hi all,

I have created a database that keeps track of students whereabouts during half term, end of term holidays etc. There are five house in the college but I am only making it for one house at the moment...subsequently there are students who whouldnt be allowed to access the system.

I was wondering if anyone could give me some vba code that will enable me to check if the currently logged in user is in the students table or not and then allocate different permissions depending on the answer.

As usual I expect that this is relatively simple...just not for me!!

If you need any further information then just ask

Cheers

James Aubrey

This can be done using a dlookup
 
Hi James,

Environ$("Username") will give you the username of the person currently logged on the computer. There are other Environ variables available that are worth looking at.

Simon B.
 
I have a module (GetCurrentUserName()) that retrieves the ID of the currently logged in user.

I also know that I need to use a DLookUp function...I just want to know the line of code that I need.

Thanks
 
For example, if in your table (let's say named tblUsers) you have a field named UserID and you have UserName then you can get it using a DLookup like:

YourControlNameHere = DLookup("UserID", "tblUsers", "[UserName]=" & Chr(34) & GetCurrentUserName & Chr(34)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom