Results 1 to 3 of 3
  1. #1
    VicLetran is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Posts
    16

    Login Form Code error?

    Hi All,

    I got this code from one of my youtube downloaded video. But it did not work. Anyone can help please!, comment. This is the code below:
    Option Compare Database


    Private Sub Command1_Click()
    If IsNull(Me.txtLoginID) Then


    MsgBox "Please enter LoginID", vdInformation, "LoginID Required"
    Me.txtLoginID.SetFocus
    Else
    'process the job
    If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtLoginID.Value & "'"))) Or _
    (IsNull(DLookup("password", "tblUser", "Password = '" & Me.txtPassword.Value & "'"))) Then
    MsgBox "Incorrect LoginID or Password"
    Else



    'MsgBox "Login and Password Correct"
    DoCmd.OpenForm "AddEmployee"

    End Sub


    Private Sub Form_Click()


    End Sub

    The result is it did not open the target form > DoCmd.OpenForm "AddEmployee".

    Please reply thanks
    Attached Thumbnails Attached Thumbnails ErrorLogin.png  

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You should really take the time to give objects meaningful names. "Command1" is a poor name - what is its purpose? If the name was "btnCheckLogIn" it tells you a lot more... yes?

    If the code for "Command1" is actually what you posted, you are missing a couple of "End If" statements:
    Code:
    Private Sub Command1_Click()
        If IsNull(Me.txtLoginID) Then
            MsgBox "Please enter LoginID", vdInformation, "LoginID Required"
            Me.txtLoginID.SetFocus
        Else
            'process the job
            If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtLoginID.Value & "'"))) Or _
               (IsNull(DLookup("password", "tblUser", "Password = '" & Me.txtPassword.Value & "'"))) Then
                MsgBox "Incorrect LoginID or Password"
            Else
                'MsgBox "Login and Password Correct"
                DoCmd.OpenForm "AddEmployee"
            End If
        End If
    End Sub
    See if that helps......

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    subs need a name...

    sub Bob()

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

Similar Threads

  1. Code for a Login Form
    By Robert2150 in forum Programming
    Replies: 3
    Last Post: 08-09-2017, 06:17 PM
  2. Replies: 1
    Last Post: 09-08-2012, 05:51 AM
  3. Restricted Access Login Code Error
    By need_help12 in forum Programming
    Replies: 6
    Last Post: 04-27-2012, 08:48 AM
  4. Login Form Code
    By paddon in forum Programming
    Replies: 4
    Last Post: 04-08-2011, 06:48 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