Results 1 to 6 of 6
  1. #1
    Gend is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2016
    Posts
    4

    Create Login for Newbie

    Hello guys..


    Can someone show me by step how to make login form?
    Im not familiar to using access but I need a security to protect my valuable data.
    I want make my file only can be access by only two people and they the only one that can change and update the data..

    Thank you.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    This uses the windows authentication.
    Make a form with text boxes, txtUser, txtPass, txtDom (domain)

    Code:
    SUB btnLogin_Click()
    Dim sUser As String, sPass As String, sDom As String
    
    sUser = txtUser
    sPass = txtPass
    sDom = txtDom
    
    If WindowsLogin(sUser, sPass, sDom) Then
       mbSafe = True
       DoCmd.OpenForm "frmMainMenu"
       DoCmd.OpenForm "frmLogin"
       DoCmd.Close
    Else
       MsgBox "LOGIN INCORRECT", vbCritical, "Bad userid or password"
    End If
    
    '-----------------
    Public Function WindowsLogin(ByVal strUserName As String, ByVal strpassword As String, ByVal strDomain As String) As Boolean
    '-----------------
    
            'Authenticates user and password entered with Active Directory.
    
            On Error GoTo IncorrectPassword
            
            Dim oADsObject, oADsNamespace As Object
            Dim strADsPath As String
            
            strADsPath = "WinNT://" & strDomain
            Set oADsObject = GetObject(strADsPath)
            Set oADsNamespace = GetObject("WinNT:")
            Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strDomain & "\" & strUserName, strpassword, 0)
            
            WindowsLogin = True    'ACCESS GRANTED
            
    ExitSub:
            Exit Function
            
    IncorrectPassword:
            WindowsLogin = False   'ACCESS DENIED
            Resume ExitSub
    End Function

  3. #3
    Gend is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2016
    Posts
    4
    can you teach me the flow to make this?
    what should I do first?

    what table should I create?
    Im appreciate if you help me

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    no table needed. This opens 2 forms, the main menu, and the login form
    frmMainMenu
    frmLogin

    user cannot get into the db until the login is correct.
    If they close the frmLogin without logging in, then the database closes via
    docmd.quit

    in the frmLogin, paste this code into the button for LOGIN click event.

  5. #5
    Gend is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2016
    Posts
    4
    the code should paste at the property sheet "on click" right?

  6. #6
    Gend is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2016
    Posts
    4
    what is txtDom for?

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

Similar Threads

  1. Create a Login Form
    By pshakti in forum Forms
    Replies: 1
    Last Post: 07-23-2014, 03:15 AM
  2. Create a Insert into From scratch for newbie
    By ryoka012 in forum Access
    Replies: 8
    Last Post: 04-07-2014, 04:17 PM
  3. Create Login With 2 Access Levels
    By WickidWe in forum Forms
    Replies: 2
    Last Post: 12-30-2013, 02:38 AM
  4. create form login with pasword
    By thomanmpku in forum Security
    Replies: 2
    Last Post: 08-29-2013, 06:32 PM
  5. Having trouble visualizing how to create a login
    By seth.murphine in forum Access
    Replies: 19
    Last Post: 04-11-2012, 03:24 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