Logged in Details ( Ms Access application

I want all the forms to show the names or title of a person logged in the application , the same way my application is able to authorize the the forms to use as per user rights, below is my code for segregation of duties:

Private Sub Form_Open(Cancel As Integer)
Dim strITAccounts As String
Dim strITManager As String
strITManager = "Managers"
strITAccounts = "Finance"
If (Forms!frmLogin!txtUserrights.Value = [strITManager]) Then
Cancel = False
Exit Sub
ElseIf Forms!frmLogin!txtUserrights.Value <> [strITAccounts] Then
MsgBox "You are not authorized to open this form!", vbOKOnly + vbExclamation, "Rights Not Granted"
Cancel = True
Exit Sub
End If
End Sub

The above profile is for an accountant now all what I want to see in all forms is a title called accountant as per profile above.Any idea??????????

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?
PatHartmanConnect With a Mentor Commented:
What form is running this code?  It looks like it is NOT frmLogin because otherwise you would refer to the form fields using Me. rather than the external Forms!yourform... style.

As long as the login form remains open but hidden, you can reference anything on it so you can add controls to the headers of your other forms that reference the fields from the login form that you want to display. for example:

ste5anSenior DeveloperCommented:
Is it a plain Access application or do you use SQL Server as back-end?
Fabrice LambertFabrice LambertCommented:

Will updating the form's Caption property be enough ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.