Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237

    Login form with error 3464

    hi guys below code works up until I fill the details in login and password and instead of processing job it comes up with a run time error 3464

    Private Sub Enter_Click()
    If IsNull(Me.txtLoginID) Then
    MsgBox "Please Enter LoginID", vbInformation, "LoginID Required"
    Me.txtLoginID.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
    MsgBox "Please Enter Password", vbInformation, "Password Required"
    Me.txtPassword.SetFocus
    Else
    'process the job


    If (IsNull(DLookup("UserLogin", "tblEmployees", "UserLogin ='" & Me.txtLoginID.Value & "'"))) Or _
    (IsNull(DLookup("Password", "tblEmployees", "Password ='" & Me.txtPassword.Value & "'"))) Then
    MsgBox "Incorrect LoginID or Password"
    Else

    End If
    End If
    End Sub

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Is it failing on the If (IsNull.... statement, or somewhere else?

    The only thing I can think of is that in tblEmployees, UserLogin is defined as numeric type.

  3. #3
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    yeah the whole If(IsNull statement gets lit up

    primary key is autonumber
    firstname, lastname, username and userlogin is in text
    password is number and department is a lookup table on number

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    password is number
    That's the problem. Your DLookup on password has the password enclosed in single quotes, which shouldn't be there for a numeric value.

    However, that leads to another potential problem - if a user enters non-numeric data in the password, you will get an error then, too. You might be better off changing the password to text type in the table, even if the data in it will only be "numeric".

  5. #5
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by John_G View Post
    That's the problem. Your DLookup on password has the password enclosed in single quotes, which shouldn't be there for a numeric value.

    However, that leads to another potential problem - if a user enters non-numeric data in the password, you will get an error then, too. You might be better off changing the password to text type in the table, even if the data in it will only be "numeric".
    you nailed It John changed password to text problem sorted.... cheers!!

  6. #6
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by ShaunG View Post
    you nailed It John changed password to text problem sorted.... cheers!!
    that sorted that issue out John.... but I have another im stuck on with the same logon form, now any one can logon using a mixture of usernames and passwords dosent have to be incorrect order and still logs on

  7. #7
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    You need to add the UserName into the criteria for the password lookup.

    Code:
    DLookup("Password", "tblEmployees", "[Password] =" & Me.txtPassword & " AND [UserLogin] ='" & Me.txtLoginID= "'")
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #8
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    not sure how that would look am I far off? I changed Userlogin to LoginID

    Private Sub Enter_Click()
    If IsNull(Me.txtLoginID) Then
    MsgBox "Please Enter LoginID", vbInformation, "LoginID Required"
    Me.txtLoginID.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
    MsgBox "Please Enter Password", vbInformation, "Password Required"
    Me.txtPassword.SetFocus
    Else
    'process the job
    If (IsNull(DLookup("LoginID", "tblEmployees", "LoginID ='" & Me.txtLoginID.Value & "'"))) Or _
    (IsNull(DLookup("Password", "tblEmployees", "[Password] =" & Me.txtPassword & " And [LoginID] ='" & Me.txtLoginID= "'")
    MsgBox "Incorrect LoginID or Password"
    Else
    'MsgBox "LoginID and Password Correct"
    DoCmd.OpenForm "CabinetTech"

    End If
    End If
    End Sub

  9. #9
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    To be honest the first check is moot as the second lookup includes it, so simplify it to one lookup.
    Code:
    If IsNull(DLookup("Password", "tblEmployees", "[Password] =" & Me.txtPassword & " And [LoginID] ='" & Me.txtLoginID= "'")) Then
         MsgBox "Incorrect LoginID or Password"
    Else
         'MsgBox "LoginID and Password Correct"
         DoCmd.OpenForm "CabinetTech"
    
    End If
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #10
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by Minty View Post
    To be honest the first check is moot as the second lookup includes it, so simplify it to one lookup.
    Code:
    If IsNull(DLookup("Password", "tblEmployees", "[Password] =" & Me.txtPassword & " And [LoginID] ='" & Me.txtLoginID= "'")) Then
         MsgBox "Incorrect LoginID or Password"
    Else
         'MsgBox "LoginID and Password Correct"
         DoCmd.OpenForm "CabinetTech"
    
    End If
    comes up with the "Incorrect LoginID or Password message" only with the correct login details

    Private Sub Enter_Click()
    If IsNull(DLookup("Password", "tblEmployees", "[Password] =" & Me.txtPassword & " And [LoginID] ='" & Me.txtLoginID = "'")) Then
    MsgBox "Incorrect LoginID or Password"
    Else
    'MsgBox "LoginID and Password Correct"
    DoCmd.OpenForm "CabinetTech"
    End If

    End Sub

  11. #11
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by Minty View Post
    To be honest the first check is moot as the second lookup includes it, so simplify it to one lookup.
    Code:
    If IsNull(DLookup("Password", "tblEmployees", "[Password] =" & Me.txtPassword & " And [LoginID] ='" & Me.txtLoginID= "'")) Then
         MsgBox "Incorrect LoginID or Password"
    Else
         'MsgBox "LoginID and Password Correct"
         DoCmd.OpenForm "CabinetTech"
    
    End If

    cheers for the help Minty but I couldn't get it to work.... I found this and manage to get it working cheers again.

    Option Compare Database

    Private Sub Enter_Click()
    Dim User As String
    Dim UserLevel As Integer
    Dim TempPass As String
    Dim ID As Integer
    Dim UserName As String
    Dim TempID As String

    If IsNull(Me.txtLoginID) Then
    MsgBox "Please enter UserName", vbInformation, "Username required"
    Me.txtLoginID.SetFocus
    ElseIf IsNull(Me.txtPassword) Then
    MsgBox "Please enter Password", vbInformation, "Password required"
    Me.txtPassword.SetFocus
    Else
    If (IsNull(DLookup("LoginID", "tblEmployees", "LoginID = '" & Me.txtLoginID.Value & "' And Password = '" & Me.txtPassword.Value & "'"))) Then
    MsgBox "Invalid Username or Password!"
    Else
    TempID = Me.txtLoginID.Value
    UserName = DLookup("[UserName]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID.Value & "'")
    UserSecurity = DLookup("[UserSecurity]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID.Value & "'")
    TempPass = DLookup("[Password]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID.Value & "'")
    LoginID = DLookup("[LoginID]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID.Value & "'")
    DoCmd.Close
    If (TempPass = "password") Then
    MsgBox "Please change Password", vbInformation, "New password required"
    DoCmd.OpenForm "frmUserinfo", , , "[LoginID] = " & LoginID
    Else
    'open different form according to user level
    If UserLevel = 1 Then ' for Director
    DoCmd.OpenForm "CabinetTech Form"
    Else
    DoCmd.OpenForm "JobProgress"
    End If
    End If
    End If
    End If
    End Sub
    Private Sub Form_Load()
    Me.txtLoginID.SetFocus
    End Sub

  12. #12
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Are you sure? In the immediate window hard code some values - type the following substituting known good values in the Red bits;

    Code:
    ?  DLookup("Password", "tblEmployees", "[Password] = 13 And [LoginID] ='APassword'")
    Edit: Okay so now you have changed Password to a text - I'm not surprised it didn't work.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by Minty View Post
    Are you sure? In the immediate window hard code some values - type the following substituting known good values in the Red bits;

    Code:
    ?  DLookup("Password", "tblEmployees", "[Password] = 13 And [LoginID] ='APassword'")
    Edit: Okay so now you have changed Password to a text - I'm not surprised it didn't work.
    yeah not sure myself why I couldn't get It to work im a noob at databases.... surprised I got the above to work but happy. lol t
    hanks for the help

  14. #14
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Here is a neater way of writing the same thing. See how the logic flow is more obvious without all the IF ..Else.. ElseIF constructs.
    Code:
    Private Sub Enter_Click()
        Dim User             As String
        Dim UserLevel        As Integer
        Dim TempPass         As String
        Dim ID               As Integer
        Dim UserName         As String
        Dim TempID           As String
    
    
        If IsNull(Me.txtLoginID) Then
            MsgBox "Please enter UserName", vbInformation, "Username required"
            Me.txtLoginID.SetFocus
            Exit Sub
        End If
    
    
        If IsNull(Me.txtPassword) Then
            MsgBox "Please enter Password", vbInformation, "Password required"
            Me.txtPassword.SetFocus
            Exit Sub
        End If
    
    
        If (IsNull(DLookup("LoginID", "tblEmployees", "LoginID = '" & Me.txtLoginID & "' And Password = '" & Me.txtPassword & "'"))) Then
            MsgBox "Invalid Username or Password!"
            Exit Sub
        End If
    
    
        TempID = Me.txtLoginID
        UserName = DLookup("[UserName]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID & "'")
        UserSecurity = DLookup("[UserSecurity]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID & "'")
        TempPass = DLookup("[Password]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID & "'")
        LoginID = DLookup("[LoginID]", "tblEmployees", "[LoginID] = '" & Me.txtLoginID & "'")
        DoCmd.Close
        
        If (TempPass = "password") Then
            MsgBox "Please change Password", vbInformation, "New password required"
            DoCmd.OpenForm "frmUserinfo", , , "[LoginID] = " & LoginID
        Else
            'open different form according to user level
            If UserLevel = 1 Then        ' for Director
                DoCmd.OpenForm "CabinetTech Form"
            Else
                DoCmd.OpenForm "JobProgress"
            End If
        End If
    
    
    End Sub
    Also indenting the code makes it much easier to see where the If constructs code is being followed.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  15. #15
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    that works real good.....

    I also probably don't need the temp pass info in there, we wont give out temp passwords or username, I didn't wont to mess with it to much so left it in...

    what if I was to throw security levels in the mix say -

    level 1 - director - access to everything
    level 2 - Admin - everything minus some edits to records
    Level 3 - Office - most additions no edits
    level 4 - Workshop - very slight additions no edits
    they will all be able to view

    this is my next hurdle

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Runtime error 3464
    By gunterbrink in forum Programming
    Replies: 15
    Last Post: 12-29-2016, 07:58 PM
  2. Syntax Error 3464 Need help
    By draalderks in forum Forms
    Replies: 13
    Last Post: 06-09-2015, 10:11 AM
  3. error 3464 - Password change form
    By Sheba in forum Forms
    Replies: 14
    Last Post: 10-14-2014, 11:48 AM
  4. Execution error 3464
    By Trisha in forum Access
    Replies: 3
    Last Post: 03-03-2014, 01:03 PM
  5. 3464 error received
    By TEN in forum Programming
    Replies: 10
    Last Post: 07-08-2009, 07:25 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