+ Reply to Thread
Results 1 to 7 of 7

Thread: Custom Access Login

  1. #1
    Lightning Master AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123's Avatar
    Join Date
    Mar 2008
    Location
    Fortress Of Solitude
    Posts
    394
    Rep Power
    7

    Custom Access Login

    Download attached Sample,

    This is for use with FE BE database, Make Sure that the CurrentUser Table is on the FE

    Employee Table

    Employee ID Number - AutoNumber
    Employee Name
    Employee Password Input Mask - Password
    Employee Access Level
    Forms (Or Group of forms) Yes/No

    CurrentUser Table
    CurrUser - Number - Relational to Employee ID Number - AutoNumber

    Delete Query
    To Clear current user on new session

    Login Form - FrmLogon

    Switchboard

    Admin - Admin Form (Add Users and change access right, passwords)

    Login Script,

    Code:
    'Check to see if data is entered into the UserName combo box
    
        If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
                MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
                Me.cboEmployee.SetFocus
            Exit Sub
        End If
    
    'Check to see if data is entered into the password box
    
        If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
                MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
                Me.txtPassword.SetFocus
            Exit Sub
        End If
    
    'Check value of password in Employees to see if this matches value chosen in combo box
    
        If Me.txtPassword.Value = DLookup("strEmpPassword", "Employees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
    
        lngMyEmpID = Me.cboEmployee.Value
            
        Dim stDocName As String
        Dim SQL As String
        DoCmd.SetWarnings (warningsoff)
        stDocName = "Qry_01_Login_Delete_Table"
        DoCmd.OpenQuery stDocName, acNormal, acEdit
       
        CurUser = Me.cboEmployee.Value
        SQL = "Insert InTo [CurrentUser] (CurrUser)" _
        & " Values ( '" & CurUser & "')"
                  
        DoCmd.RunSQL SQL
        DoCmd.SetWarnings (WarningsOn)
        
    
    'Close logon form and open switchboard screen
            
            DoCmd.Close acForm, "FrmLogon", acSaveNo
            DoCmd.OpenForm "Switchboard"
            
    
            Else
            MsgBox "Password Invalid.  Please Try Again", vbOKOnly, "Invalid Entry!"
            Me.txtPassword.SetFocus
            Me.txtPassword = Null
        
        End If
        
    
    End Sub
    
    Login Failure

    Code:
    'If User Enters incorrect password 3 times database will shutdown
        
        intLogonAttempts = intLogonAttempts + 1
        If intLogonAttempts > 3 Then
            MsgBox "You do not have access to this database.  Please contact your system administrator.", vbCritical, "Restricted Access!"
            Application.Quit
        End If
        
    End Sub
    
    Script for Open Form Buttons on Switchboard, based on user privileges

    Code:
    Private Sub Command0_Click()
    Dim strSQL As String
    
    strSQL = DLookup("strAccess", "Qry_CurrentUser")
    
     If strSQL = "Admin" Then
     
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "Admin"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
            Else
                MsgBox ("Sorry, you do not have access to this information")
      
                Exit Sub
            End If
    End Sub
    
    Code:
    Private Sub Command1_Click()
    Dim strSQL As String
    
    strSQL = DLookup("F1", "Qry_CurrentUser")
    
     If strSQL = -1 Then
     
     
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "Form1"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    
            Else
                MsgBox ("Sorry, you do not have access to this information")
      
                Exit Sub
            End If
    End Sub
    
    This can also be used to track table changes based on current user. If you have any question, please ask. You may decide to Disable the Shift key to secure the database window.
    Attached Files
    Last edited by AOG123; March 20th, 2009 at 12:29 PM.
    If i helped you, make me famous by clicking the

  2. #2
    Barn Newbie grovelli is an unknown quantity at this point grovelli's Avatar
    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    4

    I've downloaded your file but the VBA line
    Me.Note.SelLength = 0
    doesn't compile throwing "Error 461 Method or Data member not found"
    and you also have an undeclared variable lngMyEmpID, what's it used for?

  3. #3
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    lngMyEmpID is defined as:
    Code:
    lngMyEmpID = Me.cboEmployee.Value
    
    This is located in the routine: cmdLogin_Click of frmLogin. However, I also get the same error message and I don't see any object named Note.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  4. #4
    Barn Enthusiast sbenj69 is a jewel in the rough sbenj69 is a jewel in the rough sbenj69 is a jewel in the rough sbenj69 is a jewel in the rough sbenj69's Avatar
    Join Date
    Mar 2008
    Location
    The frigid northern plains
    Posts
    432
    Rep Power
    7

    That's weird.... it works flawlessly on my computer.....

    Just re-downloaded and checked again - no problems on my end
    Join our Folding team: DeveloperBarn Folding
    -----------------------------------
    Folding Stats - Stanford University
    Folding Stats - Extreme Over-Clocking
    Folding Stats - Kakao Stats
    Folding Stats - Xtreme CPU

    -----------------------------------

  5. #5
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    It works, but when you try to compile it you get the error.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  6. #6
    Lightning Master AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123 is a jewel in the rough AOG123's Avatar
    Join Date
    Mar 2008
    Location
    Fortress Of Solitude
    Posts
    394
    Rep Power
    7

    Hi, when i designed this i used Me.Note.SelLength = 0 to set the focus to the terms and conditons of access. I should have deleted it from this sample.
    If i helped you, make me famous by clicking the

  7. #7
    Barn Enthusiast sbenj69 is a jewel in the rough sbenj69 is a jewel in the rough sbenj69 is a jewel in the rough sbenj69 is a jewel in the rough sbenj69's Avatar
    Join Date
    Mar 2008
    Location
    The frigid northern plains
    Posts
    432
    Rep Power
    7

    Looks like he left a subroutine in there from something else.

    I removed it, and the database compiled without error.

    Here is the appended version of AOG's database.
    Attached Files
    Join our Folding team: DeveloperBarn Folding
    -----------------------------------
    Folding Stats - Stanford University
    Folding Stats - Extreme Over-Clocking
    Folding Stats - Kakao Stats
    Folding Stats - Xtreme CPU

    -----------------------------------

+ Reply to Thread

Similar Threads

  1. validation with custom validator
    By guddu in forum .NET Development
    Replies: 8
    Last Post: January 16th, 2009, 10:44 AM
  2. Custom Calendar Control
    By AOG123 in forum Access Database Samples
    Replies: 6
    Last Post: December 10th, 2008, 05:34 PM
  3. Replies: 4
    Last Post: September 22nd, 2008, 11:55 AM
  4. Custom Code Tip
    By Lauramc in forum SQL Server Reporting Services Help
    Replies: 0
    Last Post: August 6th, 2008, 09:31 PM
  5. Basic Login Script (using MS Acesss)
    By BLaaaaaaaaaarche in forum ASP Code Samples
    Replies: 0
    Last Post: March 24th, 2008, 05:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO