Results 1 to 12 of 12
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754

    password and login questions,

    HI all,
    I created a login (db attached) and I have a couple of questions now that I am wrapping it up. ProfileLogIn - Copy.zip



    So, first question is: I have a function (ValidatePwd) on form (PSWDChangePasswordFrm) that should validate that the password is from 8 to 12 charactors, should have one uppercase, one lowercase, and one number. The question is how to I call this function to work. I also had a before update event but commented it out as it just gave me a msgbox no matter what that my criteria was not met. Code still there, just don’t understand how to make it work.

    Second, How in Gods name do I get the password on Login to be case sensitive? I have read article after article, googled it, and so on and I cannot find anything that even remotely explains how I do this?

    Third, on the function (ValidatePwd) I cant make it Option Explicit due to making an empty string a variable? At least I think that’s what its asking for? How do you make ( “” ) a varible?

    Forth and Final, on (PSWDNewUserFrm) I have a variable issue too. Its asking me to declare a variable for msg? I am not sure what data type would be to declare this? I tried a lot of things but nothing corrected it so this too remains not being able to be option explicit.

    Thanks for any assistance…

    Dave

  2. #2
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    How in Gods name do I get the password on Login to be case sensitive? I have read article after article, googled it, and so on and I cannot find anything that even remotely explains how I do this?
    use StrComp() with the binary compare option

    Third, on the function (ValidatePwd) I cant make it Option Explicit due to making an empty string a variable? At least I think that’s what its asking for? How do you make ( “” ) a varible?
    Use "", I dont remember what you call the slanted ones (accent?) you have but those dont work.


    Since your assigning a string declare it as a string
    Code:
    msg = "Your security questions have not been set up. " _
    you have many undeclared variables add option explicit and it will point them out to you.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    thank you,
    Not sure yet on how to impliment the StrComp and such but have started reading about it.
    I was wondering what the heck those weird "" are too. I though maybe it was the font they used to create it? I know my keyboard doesnt have those marks?
    Thanks

  4. #4
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    You want something along the lines of
    Code:
    dim Str1 as String, Str2 as String
    Str1=Your Entered Password
    Str2=Your Stored Password
    If StrComp(Str1,Str2,0) = 0  Then . . . your password is valid
    I was wondering what the heck those weird "" are too.
    Called opening and closing double quotes. “”
    typing alt+0147 gives you “ and alt+0148 gives you ”
    As opposed to straight quotes ""
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Moke123,
    Thanks so much!
    I cannot beleive i spent all those hours trying to get my valid password to work and the whole time it was the quotes!
    Not sure why anyone would want those quotations like that but sure they have a purpose. Thanks for explaining them.

    Please excuse my stupidity on the Case Sensative stuff. I am looking at this and trying to comprehend it.
    So, at Str1= I wouldnt put "Your Entered Password" ? That would have to be a field correct?
    And also for the Str2....
    Then I would need to insert the If statement somewhere,
    If StrComp(Str1,Str2,0) =0 Then
    DoCmd.OpenForm "My Form"
    Else
    MsgBox "Password Invalid - Passwords are case sensative"
    Me.TxtPassword.SetFocus
    End If

    Or something to that affect?

    Thanks
    Dave

  6. #6
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    OK,
    So I tried this but i dont know how to get the stored password?
    I put the StrComp() into a private sub which i beleive is correct? Not real sure...
    I put a Call StrComp in before update on Me.TxtPassword
    Yet....how to i get the actual stored password form this code?
    I put in red what i dont understand in code below?
    Thanks
    Code:
    Option Compare Database
    
    Private Sub CmdExit_Click()
        DoCmd.Close
    End Sub
    
    
    Private Sub CMDLogin_Click()
    Dim UserName, Temppass As String
    Dim UserLevel, ID As Integer
    Dim TempLogin As TempVar
    Dim Str1 As String, Str2 As String
    
    
    Str1 = [TxtPassword]
    Str2 = Temppass????
    
    
    If IsNull(Me.TxtLoginID) Then
        Status "Please enter UserID"
        Me.TxtLoginID.SetFocus
    ElseIf IsNull(Me.TxtPassword) Then
        Status "Please enter Password"
        Me.TxtPassword.SetFocus
    Else
        If (IsNull(DLookup("PSWDUserID", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "' And password = '" & Me.TxtPassword.Value & "'"))) Then
            Status "Invalid LoginID or Password!"
            TxtLoginID = Null
            TxtPassword = Null
            Me.TxtLoginID.SetFocus
        Else
                TempVars!TempLogin = Me.TxtLoginID.Value
                
                UserName = DLookup("[Username]", "PSWDUserTbl", "[UserLogin] = '" & Me.TxtLoginID.Value & "'")
                UserLevel = DLookup("[UserSecurity]", "PSWDUserTbl", "[UserLogin] = '" & Me.TxtLoginID.Value & "'")
                Temppass = DLookup("[password]", "PSWDUserTbl", "[UserLogin] = '" & Me.TxtLoginID.Value & "'")
                ID = DLookup("[PSWDUserID]", "PSWDUserTbl", "[UserLogin] = '" & Me.TxtLoginID.Value & "'")
                'DoCmd.Close
            If (Temppass = "Password1") Then
                    DoCmd.Close
                    MsgBox "Please change Password", vbInformation, "New password requeired"
                    DoCmd.OpenForm "PSWDChangePasswordFrm", , , "[PSWDUserid] = " & ID
            ElseIf IsNull(DLookup("answer1", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "'")) Or IsNull(DLookup("answer2", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "'")) Or IsNull(DLookup("answer3", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "'")) Then
                    DoCmd.Close
                    msg = "Your security questions have not been set up. " _
                          & vbCr & "Do you want to set it up now?"
                    Style = vbYesNo + vbQuestion
                    Title = "Set Up Security Question?"
                    Response = MsgBox(msg, Style, Title)
                    If Response = vbYes Then
                        DoCmd.OpenForm "PSWDChangePasswordFrm", , , "PSWDUserID =" & ID
                        Exit Sub
                    End If
                    If Response = vbNo Then
    
    
                        If UserLevel = 1 Then ' for Developer
                            DoCmd.ShowToolbar "Ribbon", acToolbarYes
                            DoCmd.OpenForm "Switchboard"
                        Else
                        
                        If UserLevel = 2 Then ' for Admin
                            DoCmd.ShowToolbar "Ribbon", acToolbarYes
                            DoCmd.OpenForm "Switchboard"
                       Else
    
    
                        If UserLevel = 3 Then ' for Manager
                            DoCmd.ShowToolbar "Ribbon", acToolbarNo
                            DoCmd.OpenForm "Switchboard"
                       Else
    
    
                        If UserLevel = 4 Then ' for User
                            DoCmd.ShowToolbar "Ribbon", acToolbarNo
                            DoCmd.OpenForm "Switchboard"
                                
                                    End If
                                End If
                            End If
                        End If
                    End If
            Else
                DoCmd.Close
            
                        
                       
                        If UserLevel = 1 Then ' for Developer
                            DoCmd.ShowToolbar "Ribbon", acToolbarYes
                            DoCmd.OpenForm "Switchboard"
                        Else
                        
                        If UserLevel = 2 Then ' for Admin
                            DoCmd.ShowToolbar "Ribbon", acToolbarYes
                            DoCmd.OpenForm "Switchboard"
                       Else
    
    
                        If UserLevel = 3 Then ' for Manager
                            DoCmd.ShowToolbar "Ribbon", acToolbarNo
                            DoCmd.OpenForm "Switchboard"
                       Else
    
    
                        If UserLevel = 4 Then ' for User
                            DoCmd.ShowToolbar "Ribbon", acToolbarNo
                            DoCmd.OpenForm "Switchboard"
                    
                                    End If
                                End If
                            End If
                    End If
            End If
        End If
    End If
    End Sub
    
    
    Private Sub Form_Load()
    Me.TxtLoginID.SetFocus
    End Sub
    
    
    Private Sub Status(S As String)
        StatusLabel.Caption = S
        StatusLabel.Visible = True
    End Sub
    
    
    Private Sub StrComp()
    If Not StrComp(Str1, Str2, 0) = 0 Then
    MsgBox "Password Incorrect, Password is case sensitive"
    End If
    End Sub
    
    
    
    
    
    
    
    
    Private Sub TxtPassword_BeforeUpdate(Cancel As Integer)
    Call StrComp
    End Sub

  7. #7
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Just so i know as trying to learn,
    I found all those other varibles and would
    it not have been a lot less work just to add
    a MsgBox?

    Code:
            ElseIf IsNull(DLookup("answer1", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "'")) Or IsNull(DLookup("answer2", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "'")) Or IsNull(DLookup("answer3", "PSWDUserTbl", "UserLogin = '" & Me.TxtLoginID.Value & "'")) Then                DoCmd.Close
                    msg = "Your security questions have not been set up. " _
                          & vbCr & "Do you want to set it up now?"
                    Style = vbYesNo + vbQuestion
                    Title = "Set Up Security Question?"
                    Response = MsgBox(msg, Style, Title)
                    If Response = vbYes Then
                        DoCmd.OpenForm "PSWDChangePasswordFrm", , , "PSWDUserID =" & ID
                        Exit Sub
                    If Response = vbNo Then

  8. #8
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    I am trying to figure this out and came up with this in the before update event,
    However, it is creating an error!
    Code:
    Private Sub TxtPassword_BeforeUpdate(Cancel As Integer)
        If StrComp(Me.TxtPassword, DLookup("Password", "PSWDUserTbl", "UserLogin=" & Me.TxtLoginID), vbBinaryCompare) = 0 Then
        MsgBox "Password match"
        End If
                
    End Sub
    Error! Query expression you have entered produced this error: 'dpierce'

    I dont understand why this isnt working?
    Thanks for assistance
    Dave

  9. #9
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    I dont think thats the correct event. You would want in somewhere in the click event of cmdLogin.

    The first thing to do is make sure your dlookup returns the correct info.
    it should be
    Code:
    DLookup("Password", "PSWDUserTbl", "UserLogin=""" & Me.TxtLoginID & """")
    you have to have delimiters around the text value.

    I would store it in a variable and use that in the strcomp()
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  10. #10
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    I have been working on this all day and i got this to somewhat work, it works on first record but none of the rest?
    Code:
    Private Sub PwdMatch()
    Dim Str1 As String, Str2 As String
    
    
    Str1 = [TxtPassword]
    Str2 = DLookup("Password", "PSWDUserTbl")
    If StrComp(Str1, Str2, 0) = 0 Then
        Me.CmdLogin.Enabled = True
        Call CMDLogin_Click
        Else
        MsgBox "Password Does Not Match, Please Try Again"
        Me.CmdLogin.Enabled = False
        End If
                
    End Sub
    
    
    Private Sub TxtPassword_BeforeUpdate(Cancel As Integer)
     Call PwdMatch
    End Sub
    So, i tried this and received an error such as before? What the heck!!!!

    Code:
    Str2 = DLookup("Password", "PSWDUserTbl", "UserLogin=" & Me.TxtLoginID)
    So close but still so far....
    Dave

  11. #11
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    ProfileLogIn - Copy.zip

    Thank you Moke123,
    I put that code in and it works just fine. I do think you are correct that it should be in the Login_Click event but i have not been able to figure that out.
    I am sorry for my stupidity but i am trying to figure this out. This is what i could get to actually work for starters. I will work on it some more to see if i can
    get that code into my actual Login button code. Just not real good at these things yet....
    Thank you,
    Dave
    I attached the actual updated DB
    Again, Thank you!

  12. #12
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Thank you all,
    I have it fixed and in the correct location. Works like a charm.....
    Thanks again!
    Dave

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

Similar Threads

  1. Login Form (Password Help)
    By SlyFox2020 in forum Programming
    Replies: 1
    Last Post: 02-22-2020, 10:19 PM
  2. Password Login Error
    By adaoluz in forum Forms
    Replies: 8
    Last Post: 10-28-2018, 03:01 PM
  3. After Password Login Form
    By data808 in forum Access
    Replies: 13
    Last Post: 02-25-2014, 12:46 AM
  4. Login Form with Password
    By data808 in forum Programming
    Replies: 1
    Last Post: 02-12-2014, 01:06 PM
  5. Password ### login
    By buckwheat in forum Access
    Replies: 5
    Last Post: 09-10-2013, 11:54 AM

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