Results 1 to 10 of 10
  1. #1
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52

    Password protected Switcboard buttons

    Hi Everyone,

    I would like to place a password on two different switchboard buttons on my database. I found/downloaded a db from the web that fits my need, it has a tblEmployee and it has EmpName,EmpPassword & strAccess (Admin & User) as field names where I can create userid's and access levels. I has also form named frmLogon. On one of the switchboard button I changed the "OnClick" event to open the frmLogon but I'm lost on how to call back the switchboard button.



    Is it possible to open multiple buttons with different access levels based from the tblEmployee table? Would appreciate if you could help me code my problems

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    You could change the project to default open to the Login form. User logs in and form closes then open switchboard. Retain the user ID somewhere - global variable or textbox on switchboard. Use the ID to control what the user has access to (forms, buttons, etc).

    EDIT: Just hit me you want to restrict interaction with only certain areas of db, don't want to require every user to login, just to access those particular areas. Open the login form with the acDialog parameter and the code execution of calling procedure will suspend until the dialog form closes. The trick is how to return to the calling procedure the login values and determine if user can go on or is stopped. I have passed value by global variable and by having the dialog form set a value in an unbound textbox on the calling form. Then close the dialog form, code continues. Have code to check value in the textbox and base permission to user on that value.

    I have code that checks the user network login ID against users table. I assume if they are authorized by the Network they can use the db. If it is first time for this network ID, user must enter initials which are saved to table along with the network ID, they never have to login in again. User initials are retrieved by match to network ID and initials display on forms.
    Last edited by June7; 07-16-2011 at 07:06 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Here's a REAL rough draft of what June7 was refereing to in the first psrt of the message...

  4. #4
    alex_raju is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    56
    Public LoginSucceeded As Boolean

    Private Sub cmdCancel_Click()
    'set the global var to false
    'to denote a failed login
    LoginSucceeded = False
    Me.Hide
    End Sub

    Private Sub cmdOK_Click()
    'check for correct password
    If txtPassword = "password" Then
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmswitchboard"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    'place code to here to pass the
    'success to the calling sub
    'setting a global var is the easiest
    LoginSucceeded = True
    Me.Hide
    Else
    MsgBox "Invalid Password, try again!", , "Login"
    txtPassword.SetFocus
    SendKeys "{Home}+{End}"
    End If
    End Sub

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Further to the above suggestions, I have used the following to restrict and allow access to various parts of databases. While the thread is somewhat lengthy, it is very informative and works nicely to allow various permission levels throughout the database

    http://www.mrexcel.com/forum/showthread.php?t=248191

    Alan

  6. #6
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    Good Day Guys,

    I really appreciate all your replies but I really don't know where to begin. I'm not really good in programming or VBA.

    I have attached a DB which is very similar to my DB , it has simplified forms (Switchboard,frmAdministration, frmLogon, frmMenu1, frmMenu2, frmMenu3 and frmMenu4), including tblAdmins.

    On my Switchboard, I have Menu 1, Menu 2, Menu 3 and Menu 4.
    -Menu 1 will open frmMenu 1
    -Menu 2 will open frmMenu 2
    -Menu 3 will open frmLogon

    Once my logon credentials are OK for Menu 3 I'll be prompted will all the sub menu's (3.1, 3.2, 3.2). If I click sub menu's 3.1 and 3.2 its Ok but if I click 3.3 i'll be prompted again for the logon screen. This is because they have the same ItemNumber for Menu 3 and sub menu 3.1 (see Switchboard Items table and my code below). Is there a workaround to resolve this?
    Code:
     Forms!Switchboard.Filter = "[ItemNumber] = 3 And [SwitchboardID] = 1"
    -Menu 4 would like to use frmLogon, since I'll be using this menu for Administration purposes (with Admin rights only). Would like to have a code embedded in frmLogon to open frmAdministration.

    Your help are greatly appreciated and I really need these security features to complete my DB.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    I looked at the example db. You discuss submenus which are not in this example. How are we to evaluate what isn't built? The example db offers enough code sample for you to apply to your own project. Attempt coding and when you have specific issue post question.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    You're going to need something like this on Option3 of the Swtichboard...

    Code:
     
    Dim lngMyEmpID As Long
     
    If CurrentProject.AllForms("frmLogon").IsLoaded = False Then
    DoCmd.OpenForm "frmLogon"
    Else
    lngMyEmpID = Forms![frmLogon].cboEmployee.Value
    End If
    ...you will have to add some logic that sees frmLogon. Oh, and I changed that to be invisible and not erase the password...

    Code:
     
    Else
    'rtw Me.txtPassword = Null  <<<REMOVE
    Dim strAccessLevel As String
    strAccessLevel = DLookup("[Admins]", "tblAdmins", "[EmpID]=" & lngMyEmpID)
    If strAccessLevel = "Admin" Then
    MsgBox "Welcome " & DLookup("EmpName", "tblAdmins", "EmpID=" & lngMyEmpID)
    Me.Visible = False <<<ADD
     
    Forms!Switchboard.Filter = "[ItemNumber] = 3 And [SwitchboardID] = 1"
    ElseIf strAccessLevel = "User" Then
    MsgBox "Invalid Account", vbOKOnly, "Access Denied!"

  9. #9
    mar_t is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Nov 2010
    Posts
    52
    Thank you Gina, I'll apply your codes above and hopefully finish my project DB.

  10. #10
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Still may need some tweaking... I'll be waiting if you have questions!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Password protected form or report
    By mar_t in forum Access
    Replies: 11
    Last Post: 06-20-2013, 05:52 AM
  2. Open a password protected MDB/MDW
    By abcc14 in forum Security
    Replies: 8
    Last Post: 11-02-2011, 07:41 AM
  3. Replies: 4
    Last Post: 09-14-2011, 12:33 AM
  4. Virtual Password-Protected Connection
    By marianne in forum Sample Databases
    Replies: 6
    Last Post: 02-18-2011, 10:41 AM
  5. Replies: 1
    Last Post: 10-20-2010, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums