user access

T

tracktraining

Hi All,

I searched is forum for help on how to put password on forms (or just put
some kind of restrictions) and didn’t find anything.

I want to allow certain users to have access to certain forms in my MS
Access db. Can that be done?

When the user opens the db in Access and clicks on a form, the db should
pick up the username from Windows. Then match the username with the jobfunc
that the user is assigned to in the db. I want only certain jobfunc (users
are assigned to jobfunc) to have access (able to open, read-only, add or
delete) to certain forms.

I found the following code to get the user Windows login name. I don’t know
where to put this code or how to use it.?

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)

http://support.microsoft.com/kb/152970

Can anyone give me any suggestion on how to do this?

Thanks,
TrackTraining
 
R

Roger Carlson

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "UserSeesOnlyHisRecords.mdb". This not exactly what you are
looking for. This sample limits the records displayed in a query (and
subsequently any form based on the query) based on the user's login.
However, a similar process could be used to limit which forms, reports and
such the user can see.

At any rate, it shows where to put the function you mentioned (it uses the
same one). You can find the sample here:
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=220.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
T

tracktraining

Thank you. I will look at it and try for myself then post back for additional
questions.
 
T

tracktraining

Hi Roger,

I looked at your db. I see that you have a field for the user name to
appear. Can you give me hints on how to tell check the user and give access?

i.e. get user name from windows (so the user don't need to type in his/her
name again), then check in db, if user is assigned to user, then allow the
open to open, if the user is not assigned as user, then the form should not
open "You don't have access".

I hope to have three levels of access:
1. Superuser = allow access to tables, forms, reports, codes.. everything
2. Admin = allow access to forms, reports
3. user = allow access to only the SEARCH form and reports.

Can those access level be done as well (i.e. preventing access from tables
and codes)?

Thanks,
Tracktraining
 
T

tracktraining

Hi,

I am thinking of something like this (I know the syntax is wrong):

Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strGetLev As String

Set db = CurrentDb
Set rs = db.OpenRecordset(strGetLev)

strGetLev = "SELECT * FROM EmpInfo WHERE EmpInfo.EmpEmail = '" +
GetComputerName + "'"

If rs!AccessLev <> "User" Then
MsgBox "Access Denied"
End If

End Sub

................. GetComputerName is the login name from Windows.

Current this code doesn't work.

Please help if possible. Thx.
 
T

tracktraining

nevermind about all my past posts.. I figured it out. thanks again for your
db. After understand the code in your usercomputer module it really helped a
lot. THANKS!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top