Sign on Form

  • Thread starter Thread starter martinmike2
  • Start date Start date
M

martinmike2

Hello,

I am trying to make a form pop up when the user clicks on a tab in a
tab control. The idea is to keep the majority of the application open
and "secure" only certain portions of it by requiring a password to
the entered.


I know how to make a form open another form programmatically, my
problem is: I want to open this Sign In form when the user clicks on
a tab in a tab control. The only thing I have been able to find is
the OnClick event on the page itself and not the tab. Is this even
possible?
 
Use the tab controls On Change event to detect which tab has been clicked on.
The tab control's value will tell you which page has been selected.

You might want code like the following to keep track of the prior page.

Private Sub TabCtLPages_Change()
Static vLastPage As Variant
Debug.Print Me.TabCtLPages.Value, vLastPage
vLastPage = Me.TabCtLPages
'Do check here and reset TabCtlPages value if
'user not successful
End Sub

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
As a general rule, I try avoid requiring a user to enter a password to
access portions of an application. My approach is to expose to the user
only those objects she is authorized to use. As an example, I have a tab
control where only admin level users are allowed access to the admin tab.
What I do is hide the tab from users who are not admin users. The method is
this:

First, you can use this code in a standard module by itself (no other code)
to return the network login of the user logged in:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()

Dim Buffer As String * 20
Dim Length As Long
Dim lngresult As Long
Dim userid As String

Length = 20

lngresult = GetUserNameA(Buffer, Length)
If lngresult <> 0 Then
userid = Left(Buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
GetUserID = userid

End Function


Now, in the Form load, set the page's visible property based on the user's
level:

Me.pagAdmin.Visible = UserIsAdmin


This function will identify the user's level.

Public Function UserIsAdmin() As Boolean

UserIsAdmin = Nz(DLookup("[AdminUser]", "dbo_Employee", _
"[EmployeeLogin] = """ & GetUserID & """"), False)

End Function

Note, it does require a table with the user's login in a field and whether
they are an admin user or not.
 
Klatuu, while I agree with your practice of hiding things from people
who dont have the rights to them, I have combined the two ideas. I
have hidden the tab and then told the signin form to reveal it if the
password matches. My superiors do not want to create users for this
app, so I am forced to leave it for the most part open.


Since there is only 1 area that only certain people need access to,
they only want to sign in to get into that area.
 
Back
Top