Login Form (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
1. Your comment line
'Check case sensitivity of entered username and password is correct 'z123VF&@
is inaccurate as its only checking the password

Normally the username is not checked for case sensitivity
It should be sufficient to just check the case in the password especially if strong passwords are required

If you want to check the case of the username as well, you will need to reinstate that code

2. Apologies for the error in my code for looping through the attempts
I said it was air code based on what you had originally.
Remove the following line as it prevents the code ever progressing beyond 1:
Code:
Attempts = 0 'reset the count

Good luck
 

mba_110

Registered User.
Local time
Today, 12:41
Joined
Jan 20, 2015
Messages
280
Many many Many thanks

it is working fine.

My next step is form loading based on SecurityLevels, i think we need to make if condition to open different forms for different users level.

Code:
Select Case "SecurityLevel"

Case "Admin"
    'Full control all buttons & options ON (on frmDataEntry_Navigation i have enabled button based on "Admin").
       DoCmd.OpenForm "frmDataEntry_Navigation"
       Exit Sub
 
Case "Employee"
      'Go to Data entry menu with User Access Level (by default button is disabled on frmDataEntry_Navigation).
       DoCmd.OpenForm "frmDataEntry_Navigation"
       Exit Sub

Case "User"
       'Go to Individual record access form.
        DoCmd.OpenForm "frmEmployeeNavigation"
        Exit Sub
 
End Select

all steps are working the last step of opening the form not getting triggered and login screen stand still no opening the forms.

Please advise what i am missing.
 

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
Does the code include a section to check the security level?
It didn't previously....

e..g something like this - adapt as needed
Code:
Dim strSecurityLevel As String
strSecurityLevel = Nz(DLookup("SecurityLevel","tblUserSecurity", "UserName= ='" & strUserName & "'","")

Select Case strSecurityLevel

Case "Admin" 
 ...etc

It really would save a lot of time if you looked at the ready made example I have done. Either to use it direct or to adapt your code in a similar way to mine!
 

mba_110

Registered User.
Local time
Today, 12:41
Joined
Jan 20, 2015
Messages
280
Hi again, i have made some changes in code and pasting here again.

the problems i am facing is following

1. Even the wrong password it still opening the navigation form.
2. frmLogin is not getting closed after all verification (after opening Navigation form).
3. if i add "debug.print" before SLevels = Nz(D.... it is still not opening the navigation form after all login & Password is correct.

No error message appear while doing it, all other functions are working fine.


Code:
Private Sub BtnLoginOK_Click()
On Error GoTo Err_Handler

Dim vpwd As String
Static Attempts As Integer  'for info Static / Dim do the same thing
Dim SLevels As String
Dim strLoginID As String

'Check if username is entered.
If Nz(Me.txtUsername, "") = "" Then
        MsgBox "Username is required", vbOKOnly, "Invalid Entry!"
        Me.txtUsername.SetFocus
        Exit Sub
 End If

'Check if Password is entered.
 If Nz(Me.txtPassword, "") = "" Then
        MsgBox "Password is required", vbOKOnly, "Invalid Entry!"
        Me.txtPassword.SetFocus
        Exit Sub
    End If
  
'Check case sensitivity of entered username and password is correct 'z123VF&@'.

   Debug.Print strLoginID = Nz(DLookup("LoginID", "tblUserSecurity", "LoginID= '" & Me.txtUsername & "'"), "")

    If strLoginID <> "" Then
      Debug.Print vpwd = Nz(DLookup("strPassword", "tblUserSecurity", "LoginID='" & LoginID & "'"), "")
        
    
    If StrComp(Me.txtPassword.Value, vpwd & vbNullString, vbTextCompare) <> 0 Then
              MsgBox "Invalid Login ID and Password.", vbOKOnly, "Invalid Entry"
              Exit Sub
              End If
    End If
     

'Check if user's 3  attempts are wrong then close the database with message.
If Me.txtPassword.Value = DLookup("[strPassword]", "tblUserSecurity", "[LoginID]='" & Me.txtUsername.Value & "'") Then
     MsgBox "Welcome to Employee Management System"
     
  Else
     Attempts = Attempts + 1
     Select Case Attempts
     
     Case 1
         MsgBox "Username or password is incorrect!" & vbCrLf & _
           "Please try again", vbCritical, "Warning"
         Me.txtUsername.SetFocus
     
     Case 2
         MsgBox "You have entered an incorrect username or password twice" & vbCrLf & _
          "You have one more chance to do this correctly", vbCritical, "Warning"
         Me.txtUsername.SetFocus

     Case 3
           MsgBox "You do not have access to EMS Database, Please contact system Administrator", vbOKOnly, "Invalid Entry!"
           Application.Quit

     End Select
 End If


SLevels = Nz(DLookup("SecurityLevel", "tblUserSecurity", "[LoginID] = '" & Me.txtUsername & "'"), "")

Select Case SLevels

Case "Admin"
    'Full control all buttons & options ON (on frmDataEntry_Navigation i have enabled button based on "Admin").
       DoCmd.OpenForm "frmDataEntry_Navigation"
       Forms![frmDataEntry_Navigation]![txtAccessLevel] = Me.txtSecurityLevel
       Exit Sub
 
Case "Employee"
      'Go to Data entry menu with User Access Level (by default button is disabled on frmDataEntry_Navigation).
       DoCmd.OpenForm "frmDataEntry_Navigation"
       Forms![frmDataEntry_Navigation]![txtAccessLevel] = Me.txtSecurityLevel
       Exit Sub

Case "User"
       'Go to Individual record access form.
        DoCmd.OpenForm "frmEmployeeNavigation"
        Forms![frmEmployeeNavigation]![txtEmpLevel] = Me.txtSecurityLevel
        Forms![frmEmployeeNavigation]![txtEmpID] = Me.EmpIDtxt
        Exit Sub
End Select

Exit_Handler:
      Exit Sub

Err_Handler:
       MsgBox "Error " & Err.Number & " " & Err.Description & " iun cmdLogin_Click procedure"
       Resume Exit_Handler
End Sub
 

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
I've suggested at least twice that you look at (and possibly use) the code in my password login form but you have never responded to that suggestion.

Have you stepped through your code/used breakpoints to check what is happening?

After 23 posts and lots of code snippets, I think it is time to post the relevant parts of your database for someone to look at. Remove or change any confidential data and anything not relevant to this issue. Supply some example users/passwords for the different levels and tell us how to replicate your issues.
 

mba_110

Registered User.
Local time
Today, 12:41
Joined
Jan 20, 2015
Messages
280
I am sorry, but i want to keep my code alive that's why i didn't copy yours.


i have attached here the strip version of my database.


Anything that can make this code fully functional will be appreciated.
 

Attachments

  • Test1.zip
    96.7 KB · Views: 52

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
Please supply the info I asked for in the final sentence of my previous post.
Busy most of today but will try and look at it this evening UK time if someone else doesn’t do so first
 

mba_110

Registered User.
Local time
Today, 12:41
Joined
Jan 20, 2015
Messages
280
All relevant data (username/passwords) is stored in tblUserSecurity with access levels.

however, i will give you some brief about what i am trying to obtain.

Their are 3 type of access level
1. Admin (Full Access)

2. Employee (Same navigation form that admin have but i did make some option off on navigation form)

3. Users (Separate form with limited access)

All these above are just Levels all what i have to give access is on Navigation forms which is designed as per the access level so, from frmlogin only function have to pass correctly to navigate the Navigation form.

error in step by step process is have the part of SLevel check which is not producing the final task, which is to open navigation form after all credentials are correct, its opening either without correct password or after small tweak in code its just not opening at even the username or password is correct.

I didn't take classes of vba or study in any institute, but i learn little by little from research and practice, this is also a project for me.
 

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
Your code doesn't compile.

Before distributing apps, ALWAYS tick require variable declaration in VBE Options.
This adds Option Explicit as the second line in all code modules.
I've ticked it and done that in all existing modules.
Also added the missing bet required line Option Compare Database in your form module.

Please open the VBE and run Debug...Compile.
There is at least one error with a missing control. Fix all errors it detects and post the corrected version.
I'll check your login code later today.

UPDATE:
Replaced the attachment. I'd forgotten to reinstate the input mask on the password field

There is only one compile error - in the Form_Load event of form frmDataEntry_Navigation, this line fails as the control doesn't exist
Code:
Me.btnUserAccess.Enabled = True
For now, I'll disable that line
 

Attachments

  • Test1.zip
    83.7 KB · Views: 48
Last edited:

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
I've started to look at this but am finding it quite unstable.
Sometimes it closes immediately on starting the app.

A few initial suggestions.
Rather than putting all the code in bynLogin_Click I suggest you:
a) disable the OK button when the form loads
b) use a txtUserName_AfterUpdate event to check the user name is in the list
c) move the code to check the password to the txtPassword_AfterUpdate event. If the password matches, then enable the OK button

I've fixed the issue with the login form not closing. Very simple.
You hadn't included any code to do this!

On your form frmDataEntry_Navigation you have this code
Code:
Me.Text59 = Environ("Username")
Suggest you replace that with the LoginID e.g. Rodolfo etc

You really should give each control a meaningful name e.g. txtLoginID not Text59

Also I STRONGLY recommend you ENCRYPT the passwords if you are going to store them in the app. Using a password input mask is totally insecure

I'll look into why the password case check isn't working and your user levels either later today or tomorrow.
However I'd like to hear your views on the above before I go any further
 
Last edited:

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 15:41
Joined
Oct 17, 2012
Messages
3,276
Also I STRONGLY recommend you ENCRYPT the passwords if you are going to store them in the app. Using a password input mask is totally insecure

If the OP wants, I can provide some easy-to-use hashing functions I found for MD5, SHA1, SHA256, SHA384, and SHA512. They're basic hashing, however, and don't include salting (which may not be needed depending on the level of security you want).
 

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
Decided to go ahead with changes rather than wait for your reply.
I believe it is now working but you need to check carefully
Lots of corrections made - usually I've added comments like 'CR - disabled or whatever

For info, my password login example (see link in post 10) includes RC4 encryption which is MUCH more secure than just encoding the password.
However, anything is more secure than just using an input mask
 

Attachments

  • Test1_CR.zip
    96.7 KB · Views: 74

mba_110

Registered User.
Local time
Today, 12:41
Joined
Jan 20, 2015
Messages
280
Many thanks isladogs for your kind help.

I will let you know one thing that i didnt mentioned while you ask me to go and copy/review the code that you have for your app.

their is one thing i dont like users to know that how many people have login access which can be seen in your combo box of username, the username should be with users not necessary to put it openly in public to see who have access and who is don't have, i will definitely encrypt the password only after i am ready with my database and split it with front and back end for more protection.

I will be required your great assistance and help through out of my project which have still major goals to complete.

Honestly i learn from you a lot, and i fix my all compile errors which i was not even aware of their existence in my database and doesn't aware how to spot it through debug...compile database option.
 

isladogs

MVP / VIP
Local time
Today, 19:41
Joined
Jan 14, 2017
Messages
18,186
You can easily convert the combo back to a textbox if you prefer.
Make sure you include the code needed to validate the username as well.
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 16:41
Joined
Dec 24, 2018
Messages
150
their is one thing i dont like users to know that how many people have login access which can be seen in your combo box of username, the username should be with users not necessary to put it openly in public to see who have access and who is don't have, i will definitely encrypt the password only after i am ready with my database and split it with front and back end for more protection.

Hi mba_110! :)

I have the same feeling about it and I have managed to change the combobox to textbox after changing a few things. Please refer to my solution below:

First you need to create the txtUser and then you have to build the AfterUpdate event to handle all the code.

Create the query Colin´s using in the the cboUser´s RowSource. You can copy the SQL code after you click on the elispsis and choose the SQL View.
Copy all the information and then click "Create" and "Query Design" on the ribbon. Go to SQL view again and paste the information copied from the cboUser´s query.

Now on the txtuser_AfterUpdate() you have to do this:

Code:
Dim rs As Recordset
'2.Get user info

'Define the rs to the query´s recordset:
Set rs = CurrentDb.OpenRecordset("qryUserLogging", dbOpenSnapshot, 
dbReadOnly) 
'qryUserLogging can be replaced for the one you preffer. Just change this if you decided to another name.
The trick is that instead of using the columns´s index that Colin´s using you will have to use the query recordset you´ve just created - in my case qryUserLogging - so you will have to change all this code:

Code:
    strUserName = Me.cboUser'user name from the combo
    strComputerName = GetComputerName()
    strPassword = RC4(Me.cboUser.Column(2), "RC4_Key")
    blnChangeOwnPassword = Me.cboUser.Column(3)
    intPasswordExpireDays = Me.cboUser.Column(4)
    intAccessLevel = Me.cboUser.Column(5)
To this:

Code:
strUserName = Me.txtUser 'user name from combo
    strComputerName = GetComputerName()
    strPassword = RC4(rs!PWor.Value, "RC4_Key")
    blnChangeOwnPassword = rs!ChangePWD.Value
    intPasswordExpireDays = rs!ExpireDays.Value
    intAccessLevel = rs!AccessLevel.Value
Also you have to reset the rs at the end of the code:
Code:
Set rs = Nothing
Don´t forget that you will have to track the entire module to change all the "cboUser" and replace it with the adequate piece of code as per above. I used Ctrl+F to track it faster.

For instance, this piece is located a little bit below on the AfterUpdate event:
Code:
'3. Does the user have a current password
'If DecryptKey(Me.cboUser.Column(4)) = "Not Set" Then
'If RC4(Me.cboUser.Column(2), "RC4_Key") = "Not Set" Then 'Comment this out and add the piece below:
If RC4(rs!PWor.Value, "RC4_Key") = "Not Set" Then
Make sure you have scanned all the code to replace it accordingly.

The last part is that the cboUser´s cboUser_NotInList event must be moved to AfterUpdate event as well because that code is checking if the user exists on the database. But you will have to write the validation... I am at that point now and I can post the code later.

If you preffer to make sure the username get upper case you can use the Me.txtuser.value = UCASE(me.txtuser.value) on the after update before writing it to the logging query.

Another thing is that you can comment out all the code from cboUser so that if you decide to use it later you can ucomment it and comment all the code I am providing.

Let me know if that works!

@Isladogs, Let me know if that is reasonable enough! :D

That would be my second time adding "2 cents"...:cool:
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 16:41
Joined
Dec 24, 2018
Messages
150
If the OP wants, I can provide some easy-to-use hashing functions I found for MD5, SHA1, SHA256, SHA384, and SHA512. They're basic hashing, however, and don't include salting (which may not be needed depending on the level of security you want).

Hi Frothingslosh!

I would like to see that! Can you post/point them?:D

Thanks!
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 15:41
Joined
Oct 17, 2012
Messages
3,276
I've seen them online in a number of places, so I can't attribute them. One location you can pull them from is https://en.wikibooks.org/wiki/Visual_Basic_for_Applications/String_Hashing_in_VBA. I'm providing the link instead of just copying and pasting the code because there's other useful information there.

Please note that, although the page says that you need to set a reference to mscorlib 4.0 64-bit, they run just fine on my Access 365 install without that reference set, and they also worked fine in Access 2007 before I got upgraded.

I prefer a slightly different test function that allows you to provide the string to be hashed:

Code:
Sub Test(ByVal TestText As String)
    [COLOR="SeaGreen"]'run this to test sha1, sha2/256, or sha2/512[/COLOR]
    Dim sIn As String, sOut As String, bB64 As Boolean, sH As String
    
    [COLOR="seagreen"]'insert the text to hash within the sIn quotes
    'note that a private string could be joined to sIn at this point[/COLOR]
    sIn = TestText
    
    [COLOR="seagreen"]'select as required[/COLOR]
    bB64 = False   [COLOR="seagreen"]'output hex[/COLOR]
[COLOR="seagreen"]'    bB64 = True   'output base-64[/COLOR]
    
    [COLOR="seagreen"]'enable any one
    'sH = MD5(sIn, bB64)
    'sH = SHA1(sIn, bB64)
    'sH = SHA256(sIn, bB64)
    'sH = SHA384(sIn, bB64)[/COLOR]
    sH = SHA512(sIn, bB64)
    
    Debug.Print sH & vbNewLine & Len(sH) & " characters in length"
    MsgBox sH & vbNewLine & Len(sH) & " characters in length"
   
End Sub
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 16:41
Joined
Dec 24, 2018
Messages
150
...
The last part is that the cboUser´s cboUser_NotInList event must be moved to AfterUpdate event as well because that code is checking if the user exists on the database. But you will have to write the validation... I am at that point now and I can post the code later.
...

I forgot to post the code after I finished the validation after turning the cboUser to txtUsername!:eek:

During some texts I noticed my previous post had a MAJOR FLAW as it was not returning the username correctly BUT the first username saved on the table, so I had to change it, removing the recorset from it and working on the qryUserLogging:

Code:
strPassword = RC4(DLookup("PWor", "qryUserLogging", strUser), "RC4_Key")
blnChangeOwnPassword = DLookup("ChangePWD", "qryUserLogging", strUser)
intPasswordExpireDays = DLookup("ExpireDays", "qryUserLogging", strUser)
intAccessLevel = DLookup("AccessLevel", "qryUserLogging", strUser)
lngPasswordDate = DLookup("PWDDate", "qryUserLogging", strUser)
The complete code:

It is important to replace the cbo.User to the rest of the other events using these DLookups above, specially the one that decrypts the password.

Code:
Private Sub txtUsername_AfterUpdate()
'CHECK IF THE USERNAME EXISTS IN DATABASE AND ALSO IF THE USER IS ALREADY LOGGED IN ELSEWHERE.
'On Error GoTo Err_Handler:
'Format and Reset controls.
    Me.lblOld.Caption = "PASSWORD"
        Me.txtOldPWD = ""
            Me.txtUsername = UCase(Me.txtUsername)
    
'1. TEST IF THE USERNAME EXISTS
  
'Pass the username to the string
  Dim strCriteria As String
    strCriteria = "UserName='" & Me.txtUsername & "' And LogoutEvent Is Null"
                strUser = "Username='" & Me.txtUsername & "'"
    'TEST IF THE USER EXISTS
        Select Case Not DCount("*", "qryUserLogging", strUser) > 0
                
                Case True
                    FormattedMsgBox "Username " & Me.txtUsername & " is not saved." & "    " & _
                        "@Please review the information and try again.            @", vbCritical, "USER NOT FOUND"
                
                Case False
                    
                    '2. CHECK IF USER LOGGED ELSEWHERE
                       
                         'Search for the user on the table sessions.
                            If DCount("*", "tblLoginSessions", strCriteria) > 0 Then
                                'User is found, return the computer name he is logged.
                                    If DLookup("ComputerName", "tblLoginSessions", strUser) <> GetComputerName Then
                                        'Tell all about it to the user.
                                             FormattedMsgBox "User " & Me.txtUsername & " is already logged in at workstation " & DLookup("ComputerName", "tblLoginSessions", strCriteria) & "      " & _
                                                 "@User " & Me.txtUsername & " MUST logout from that computer before logging in again            @", vbCritical, "Already logged in"
                                                    'disable the Login button
                                                         Me.cmdLogin.Enabled = False
                                                            'Empty the txtUsername
                                                                 Me.txtUsername = ""
                                        Exit Sub
                                    Else
                                    ' If the user is not logged then end previous session for this user on current computer so a new session can be started
                                         CurrentDb.Execute "UPDATE tblLoginSessions SET LogoutEvent = Now()" & _
                                             " WHERE UserName=GetUserName() AND LogoutEvent Is Null AND ComputerName=GetComputerName();"
                                    End If
                            End If
                    
                    '3.GET USER INFO
                        If Trim(Me.txtUsername & "") <> "" Then
                            strUsername = Me.txtUsername
                                strComputerName = GetComputerName()
                                    strPassword = RC4(DLookup("PWor", "qryUserLogging", strUser), "RC4_Key")
                                        blnChangeOwnPassword = DLookup("ChangePWD", "qryUserLogging", strUser)
                                            intPasswordExpireDays = DLookup("ExpireDays", "qryUserLogging", strUser)
                                                intAccessLevel = DLookup("AccessLevel", "qryUserLogging", strUser)
                                                    lngPasswordDate = DLookup("PWDDate", "qryUserLogging", strUser)
                        End If
                    
                    '4. CHECK IF THE USER HAS A CURRENT PASSWORD
                        If RC4(DLookup("PWor", "qryUserLogging", strUser), "RC4_Key") = "Not Set" Then
                            bFlag = False
                                FormattedMsgBox "You have not set a login password yet.         " & _
                                    "@You must setup a password before you can access the application.          @", vbExclamation + vbOKOnly, "Setup Login Password"
                                        Me.txtOldPWD.Visible = False
                                            Me.txtNewPWD.Visible = True
                                                Me.txtConPWD.Visible = True
                                                    Me.txtNewPWD.SetFocus
                                                        Me.lblNew.Caption = "NEW PASSWORD"
                                                            Me.lblCon.Caption = "CONFIRM PASSWORD"
                                                                Exit Sub
                        Else
                            bFlag = True
                                Me.txtOldPWD.Visible = True
                                    Me.txtNewPWD.Visible = False
                                        Me.txtConPWD.Visible = False
                        End If
                    
                    '5. IF THE USER HAS A PASSWORD AND HE CAN CHANGE HIS OWN PASSWORD ONCE IT IS DUE TO EXPIRE.
                        
                        'Calculate the expiration date of the password.
                            If bFlag = True And intPasswordExpireDays > 0 And blnChangeOwnPassword = True Then
                                Dim DaysLeft As Integer, DateExpire As Date
                                     DateExpire = DateAdd("d", intPasswordExpireDays, lngPasswordDate)
                                         DaysLeft = DateDiff("d", Date, DateExpire)
                                        
                                        'Which option to choose
                                            Select Case DaysLeft
                                                ' Mandatory change
                                                    Case Is < 0
                                                        FormattedMsgBox "Your password has expired and must be changed now.        " & _
                                                            "@First enter your OLD password              @", vbExclamation + vbOKOnly, "PASSWORD EXPIRED"
                                                                Me.txtOldPWD.Visible = True
                                                                    Me.lblOld.Caption = "OLD PASSWORD"
                                                                        Me.lblNew.Caption = "NEW PASSWORD"
                                                                            Me.lblCon.Caption = "CONFIRM PASSWORD"
                                                                                bReset = True
                                        
                                        'Optional change
                                            Case Is < 8
                                                If FormattedMsgBox("Your password expires in " & DaysLeft & " day(s).        " & _
                                                     "@Do you want to change it now?           @", vbQuestion + vbYesNo, "PASSWORD ABOUT TO EXPIRE") = vbYes Then
                                                        
                                                        'Change the controls on the form:
                                                        Me.txtOldPWD.Visible = True
                                                            Me.txtNewPWD.Visible = True
                                                                Me.txtConPWD.Visible = True
                                                                    Me.lblOld.Caption = "OLD PASSWORD"
                                                                        Me.lblNew.Caption = "NEW PASSWORD"
                                                                            Me.lblCon.Caption = "CONFIRM PASSWORD"
                                                                                bReset = True
                                            End If
                                        
                                        ' Not applicable for change
                                            Case Else
                                                Me.lblOld.Caption = "PASSWORD"
                                                    bReset = False
                                    
                                    End Select ' Finish Which option to choose
                        
                        End If ' Finish calculation of the expiration date of the password.
        
        End Select ' Finish testing if the user exists
'6. CHECK WHICH CONTROL TO GO
    If bFlag = False Then
        If Me.txtNewPWD.Visible = True Then
            Me.txtNewPWD.SetFocus
        End If
    Else
        If Me.txtOldPWD.Visible = True Then
            Me.txtOldPWD.SetFocus
        End If
    End If
Exit_Handler:
 
Exit Sub
'-----------------------------  ERROR HANDLER  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Err_Handler:
MsgBox "An error occurred, please contact the administrator and inform the details below:" & vbCrLf & vbCrLf & _
                "Originated on form: " & Me.Name & ", procedure " & Application.VBE.ActiveCodePane.CodeModule.ProcOfLine(Application.VBE.ActiveCodePane.TopLine, 0) & ", error Line: " & Erl & vbCrLf & _
                vbCrLf & "Error Description: " & Err.Number & " - " & Err.Description, vbExclamation, "APPLICATION ERROR"
Resume Exit_Handler
End Sub
PS: I like to cascade the actions on the VBA code window when I am adding the comments to remind me later how it operates - It is second nature to me now. It is not a movement to start an art form in coding! :)
 
Last edited:

Users who are viewing this thread

Top Bottom