[AccessD] Protecting a subform with password

Jim Lawrence (AccessD) accessd at shaw.ca
Sat Sep 4 11:25:16 CDT 2004


Hi Kostas:

Add some code something like the following and the command button that opens
the subform will
be set appropriately.

In the Form Load subroutine

Private Sub Form_Load()

 ' Maybe something like....

 if CheckUsername() < 5 then
   ' Disable command button and make subform invisible.
   Me.cmbOpenSubForm.Enabled = False
   Me!MySubform.Form.Visible = False
 else
   Me.cmbOpenSubForm.Enabled = True
   Me!MySubform.Form.Visible = True
 end if

End Sub

Private Function CheckUsername() As Integer

 Dim intSecurityLevel as Integer

 IntSecurityLevel = 0

 ' add code here....
 ' In here you would put code that either asks for the username
 ' and then validates it's level of access against a protected table,
 ' value or an imbedded list or current users in the Access security
 ' tables.

 ' This example checks which security group the
 ' current user is in then sets the security level.
 If CurrentUser() = "Admin" Then intSecurityLevel = 5

 CheckUsername()  = intSecurityLevel

End Function

This is not a complete answer but hope this starts you on your way.

Jim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Kostas
Konstantinidis
Sent: Saturday, September 04, 2004 4:03 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Protecting a subform with password


Hi group,

On a main form I use a button which opens a subform.
Is it possible to protect the subform asking a password before?

Thank's
kostas

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list