Security: Create Custom Login Screen

Tuesday, February 11, 2003 23:38:07
home

If you wish to create your own custom login screen for a secured database, this is possible in an off-handed way--by creating another database strictly for this purpose which opens the actual secured database. Steps:

  1. Create a new blank, unsecured database
  2. Create a new form, with the following properties:
    Tab
    Property
    Setting
    Format Caption Enter your User ID & Password
      Record Selectors No
      Navigation Buttons No
      Control Box No
      Min Max Buttons None
      Close Button No
    Other Menu Bar =1
      Allow Design Changes (Access 2000 only) Design View Only
  3. Name the form frmLogin
  4. Create two textboxes on the form, named txtUser and txtPassword
  5. Create a Password Input Mask for the txtPassword text box
  6. Create two command buttons on the form, named cmdOK and cmdCancel
  7. Assign DoCmd.Quit to the On Click event procedure of the cmdCancel button
  8. Assign the following code to the On Click event procedure of the cmdOK button
    (the red portions will vary and thus need to be modified depending on your situation; the rest of the code is a verbatim copy/paste)
    Private Sub cmdOK_Click()
    ' strAccessPath is the path to execute Access, usually close to what is shown here
    ' strDBasePath is the path where your database is located
    ' strWkgrpPath is the path where your workgroup security file is located
    Dim strPath As String
    Dim strAccessPath As String, strDBasePath As String, strWkgrpPath As String
    strAccessPath = "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"
    strDBasePath = "T:\Accounting\PO Invoicing\po_invoices2k.mde"
    strWkgrpPath = "T:\Accounting\PO Invoicing\workgroup.MDW"
    strPath = Chr(34) & strAccessPath & Chr(34) & " " & Chr(34) & strDBasePath _
     & Chr(34) & " " & "/wrkgrp " & Chr(34) & strWkgrpPath & Chr(34) & " " _
        & "/User " & Chr(34) & Me![txtUser] & Chr(34) & " " _
        & "/Pwd " & Chr(34) & Me![txtPassword] & Chr(34)
    
    ' Debug.Print strPath    ' Uncomment this line to have the strPath
    ' variable displayed in the immediate window
    
    Shell strPath, vbMaximizedFocus
    Application.Quit
    End Sub
    
  9. Set this form up to load in the databases' startup options
  10. Remove all other startup options
  11. Optional: Disable Shift Key Bypass, disable form closing and save this as an MDE File