+ Reply to Thread
Results 1 to 6 of 6

Thread: Login Form

  1. #1
    Registered User
    Join Date
    10-17-2010
    Location
    Naga, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    34

    Login Form

    hi i make a simple loginform in my data base but i cant work it out.. here is the details in my login form


    table name: login
    consist of the following:
    Field1: ID
    Field2: Username
    Field3: Password

    and i make a login form

    combobox dropdown menu only username shows
    Textbox for password input
    and a command button for Login..
    here is the code behind the button login



    Private Sub Command3_Click()
    
    'Check to see if data is entered into the UserName combo box
    
        If IsNull(Me.login) Or Me.login = "" Then
          MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
            Me.login.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 username to see if this
        'matches value chosen in combo box
    
        If Me.txtPassword.Value = DLookup("password", "username", _
                "[ID]=" & Me.login.Value) Then
    
            lngMyEmpID = Me.login.Value
    
            'Close logon form and open splash screen
    
            DoCmd.Close acForm, "frmLogon", acSaveNo
            DoCmd.OpenForm "frmSplash_Screen"
    
        Else
          MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
                "Invalid Entry!"
            Me.txtPassword.SetFocus
        End If
    
        '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 admin.", _
                   vbCritical, "Restricted Access!"
            Application.Quit
        End If
    
    End Sub
    but when i click the login button after i put the username and password a error and im being redirect to VB code...

    any help will be appreciated..... thank you in advance...
    Last edited by phatus; 11-06-2010 at 11:53 PM.

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Login Form

    To begin with, you have control names in your code that don't exist on yur form. ie. On your form you have a control called Password, yet in your code you use txtPassword. You need to make sure that you are consistent with your naming conventions. Check all of your code and make sure that your controls that you are naming in the code are the same. It will never work if they are different.

    Alan

  3. #3
    Registered User
    Join Date
    10-17-2010
    Location
    Naga, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Login Form

    what i did is import the login form to my database and in splashscreen i create a button that will direct to my form ^ ^...

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,616

    Re: Login Form

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Login Form

    Regardless of where you get your form, import or build, you need to make sure that the code that operates the form is consistently named.

    Alan

  6. #6
    Registered User
    Join Date
    10-17-2010
    Location
    Naga, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Login Form

    i understand thanks alan... now im done with my data base...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.2.0