Results 1 to 3 of 3
  1. #1
    cap.zadi is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    Error 94 in DoLogin Procedure: Invalid use of Null!

    Dear Expert



    Can any one help to resolve this issue which display a message at login form and the code is as below:

    Code:
    Private Sub CmdLogin_Click()
    
    On Error GoTo Err_Handler
    
    
    'First thing needed is to decide which option to take
    'If there is an entry in the txtOldPwd field this is an existing password
    'If there is an entry in the txtConPwd field this is a new password setup
    'If there is an entry in all three then the user has reset their password
    
    
    '1. If password has been reset then all the validation has taken place
        'so can open the main menu straight away
        If bReset = True Then
            DoLogin
            Exit Sub
        End If
    
    
    '2. check a password has been entered
        If Trim(Me.txtOldPWD & "") <> "" Then
            'does it match the users password
           ' If Trim(Me.TxtOldPWD & "") <> DecryptKey(Me.cboUser.Column(2)) Then
            If Trim(Me.txtOldPWD & "") <> RC4(Me.cboUser.Column(2), "RC4_Key") Then
                'No Match - 3 attempts allowed
                Attempts = Attempts + 1
                
                Select Case Attempts
                Case 1
                    FormattedMsgBox "Invalid Password            " & _
                        "@Please try again      @", vbInformation + vbOKOnly, "Password Error"
                    Me.txtOldPWD = ""
                
                Case 2
                        FormattedMsgBox "You have entered an incorrect password TWICE           " & _
                        "@You have ONE more attempt left      @", vbExclamation + vbOKOnly, "Password Error"
                    Me.txtOldPWD = ""
                
                Case 3
                    FormattedMsgBox "You have entered an incorrect password THREE times         " & _
                        "@The application will now close          @", vbCritical + vbOKOnly, "Password entry failed"
                    Application.Quit
                    Exit Sub
                    
                End Select
                
            End If
            
            'Create a login event for this user
            DoLogin
        Else
            'Has the user got a password
           ' If DecryptKey(Me.cboUser.Column(2)) <> "Not Set" Then
            If RC4(Me.cboUser.Column(2), "RC4_Key") <> "Not Set" Then
                'allow 3 attempts
                 Attempts = Attempts + 1
                
                Select Case Attempts
                Case 1
                     FormattedMsgBox "You must enter your password first   " & _
                        "@Please try again          @", vbExclamation + vbOKOnly, "Password REQUIRED"
                    Me.txtOldPWD = ""
                
                Case 2
                        FormattedMsgBox "You must enter your password first   " & _
                        "@You have ONE more attempt left      @", vbExclamation + vbOKOnly, "Password REQUIRED"
                    Me.txtOldPWD = ""
                
                Case 3
                    FormattedMsgBox "Maximum number of attempts has been reached" & _
                        "@The application will now close      @", vbExclamation + vbOKOnly, "Login aborted"
                    Application.Quit
                    Exit Sub
                    
                End Select
                
            End If
            
    '3. New password setup
            'Compare both both entries as matching
            'Is there an entry in either of the text boxes
            If Trim(Me.txtNewPWD & "") = "" Then
                FormattedMsgBox "You must enter a new password.       " & _
                    "@Cannot be left blank.            @", vbExclamation + vbOKOnly, "Invalid Password"
                Exit Sub
            End If
            
            If Trim(Me.txtConPWD & "") = "" Then
                FormattedMsgBox "You must confirm the new password.         " & _
                    "@Cannot be left blank.           @", vbExclamation + vbOKOnly, "Invalid Password Confirmation"
                Exit Sub
            End If
            
            'do they match
            If Trim(Me.txtNewPWD & "") <> Trim(Me.txtConPWD & "") Then
                FormattedMsgBox "Error   " & _
                    "@Passwords do not match.            @", vbExclamation + vbOKOnly, "Invalid Password Confirmation"
                Me.txtConPWD.SetFocus
                Exit Sub
            Else
                'they both match so we can update the users record with the new password
                strPassword = Me.txtConPWD
                
             '   CurrentDb.Execute "UPDATE tblUsers SET PWD = EncryptKey(strPassword), PWDDate = Date()" & _
                    " WHERE UserName = '" & GetUserName() & "';"
                
                CurrentDb.Execute "UPDATE tblUsers SET PWD = RC4(strPassword,'RC4_Key'), PWDDate = Date()" & _
                    " WHERE UserName = '" & GetUserName() & "';"
                
                FormattedMsgBox "Your password has been updated" & _
                    "@Click Login to continue       @", vbInformation + vbOKOnly, "Password Updated"
        
                'Create a login event for this user
                DoLogin
            End If
                
        End If
    
    
    Exit_Handler:
        Exit Sub
        
    Err_Handler:
        MsgBox "Error " & Err.Number & " in cmdLogin_Click procedure: " & Err.Description
        Resume Exit_Handler
    
    
    End Sub

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Which line of code breaks and causes the error
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    The code is taken from my example PasswordLogin app.
    Check you have the latest version (5.3) which incudes various bug fixes and may well solve your issue.
    Its available from https://www.access-programmers.co.uk...2#post-1670494 or my website (but that appears to be down right now)

    EDIT:
    1. My website is back up again. The other link is: http://www.mendipdatasystems.co.uk/p...gin/4594469149
    2. The thread title states the null error occurs in the DoLogin procedure. However, you posted the cmdLogin_Click procedure code which means nobody would be able to help you solve the issue
    Last edited by isladogs; 07-28-2020 at 04:24 PM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 22
    Last Post: 04-04-2018, 10:57 AM
  2. Replies: 2
    Last Post: 04-27-2015, 02:23 PM
  3. Invalid Procedure Call error - MS Access
    By Saleem13 in forum Access
    Replies: 5
    Last Post: 10-23-2013, 11:36 AM
  4. Replies: 9
    Last Post: 12-08-2012, 04:56 PM
  5. Replies: 9
    Last Post: 08-10-2012, 03:10 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