Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit Access to Specific Forms 2

Status
Not open for further replies.

DeLaMartre

Technical User
Dec 26, 2001
213
US
Is there a relatively simple way (being simple-minded...) to limit access to a particular form for which there is a button on the switchboard? I want to make one of the forms accessible only to the manager of the department.

Could a password be assigned to a button/form?

Any help would be greatly appreciated.

Thanks very much,

-Bob in California

 
Hi

Easiest way is probably by checking the user Network login id and limiting access by that means

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks for the reply, Ken. Sorry, but I am not sure I understand entirely (I'm an Excel guy...). Could you please explain just a bit more.

Thank you,



-Bob in California

 
Hi

I hestiated to give more info, since this (although basically simple) can become hard to explain

I assume you haev a button which fires off a docmd.openform in its on click event

To begin, the function below will return the Network UserId

Option Compare Database

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function bisOSUserName() As String
' Returns id of Logged in User
Dim lngLen As Long, lngX As Long
Dim strUserName As String
'
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
bisOSUserName = Left(strUserName, lngLen - 1)
Else
bisOSUserName = ""
End If
End Function

I would have a table of UsersId and the Form(s) they can access, so I would have code something like

Dim strSQL as string
strSQL = "SELECT * FROM tblTables WHERE USerId = '" & bisOSUserName & "';"
Set Db = CurrentDb()
set rs = db.OpenREcordset(strSQL)
If Rs.Recordcount > 0 Then
docmd.openform ...etc
else
msgbox "Sorry no access to this form"
end if

Another ploy would be to simply hide the button if the suer did not have access

as I say more than one way to skin a cat, but I think I have given you the basic idea



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
What a star: solved a problem I didn't know I had. It's people like Ken Reay that make people like me look good!
 
Ken,

You are truly a gentleman and a scholar. Your dissertation in this regard was creative, thorough, and very much appreciated by this mere mortal.

Thank you so much for your time and expertise.

Regards,

-Bob in California

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top