User Name

mithani

Registered User.
Local time
Tomorrow, 04:05
Joined
May 11, 2007
Messages
291
Hello,

Can anyone help me please.

I have got my own user password screen which protect my software to use unauthorized person.

What I am looking for is, I want to display username on everyscreen. How would I save a current user?. Here is a code of user password screen

Code:
[FONT=Calibri]Private Sub cmdLogin_Click()[/FONT]
 
[FONT=Calibri] If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then[/FONT]
[FONT=Calibri]   MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"[/FONT]
[FONT=Calibri]     Me.cboEmployee.SetFocus[/FONT]
[FONT=Calibri]     Exit Sub[/FONT]
[FONT=Calibri] End If[/FONT]
 
[FONT=Calibri] If IsNull(Me.txtpassword) Or Me.txtpassword = "" Then[/FONT]
[FONT=Calibri]   MsgBox "You must enter a Password.", vbOKOnly, "Required Data"[/FONT]
[FONT=Calibri]     Me.txtpassword.SetFocus[/FONT]
[FONT=Calibri]     Exit Sub[/FONT]
[FONT=Calibri] End If[/FONT]
 
[FONT=Calibri] If Me.txtpassword.Value = DLookup("strEmpPassword", "tblEmployees", _[/FONT]
[FONT=Calibri]         "[lngEmpID]=" & Me.cboEmployee.Value) Then[/FONT]
[FONT=Calibri]     lngMyEmpID = Me.cboEmployee.Value[/FONT]
[FONT=Calibri]     DoCmd.Close acForm, "frmDatabaseLogon", acSaveNo[/FONT]
[FONT=Calibri] Else[/FONT]
[FONT=Calibri]   MsgBox "Password Invalid. Please Try Again", vbOKOnly, _[/FONT]
[FONT=Calibri]         "Invalid Entry!"[/FONT]
[FONT=Calibri]     Me.txtpassword.SetFocus[/FONT]
[FONT=Calibri] End If[/FONT]
 
 
[FONT=Calibri] intLogonAttempts = intLogonAttempts + 1[/FONT]
 
[FONT=Calibri] If intLogonAttempts = 3 Then[/FONT]
[FONT=Calibri]   MsgBox "You do not have access to this database.Please contact admin.", _[/FONT]
[FONT=Calibri]            vbCritical, "Restricted Access!"[/FONT]
[FONT=Calibri]     Application.Quit[/FONT]
[FONT=Calibri] End If[/FONT]
[FONT=Calibri]End Sub[/FONT]

I appreciate your help
mithani
 
Last edited:
Hello,

Can anyone help me please.

I have got my own user password screen which protect my software to use unauthorized person.

What I am looking for is, I want to display username on everyscreen. How would I save a current user?. Here is a code of user password screen

Code:
[FONT=Calibri]Private Sub cmdLogin_Click()[/FONT]
 
[FONT=Calibri] If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then[/FONT]
[FONT=Calibri]   MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"[/FONT]
[FONT=Calibri]     Me.cboEmployee.SetFocus[/FONT]
[FONT=Calibri]     Exit Sub[/FONT]
[FONT=Calibri] End If[/FONT]
 
[FONT=Calibri] If IsNull(Me.txtpassword) Or Me.txtpassword = "" Then[/FONT]
[FONT=Calibri]   MsgBox "You must enter a Password.", vbOKOnly, "Required Data"[/FONT]
[FONT=Calibri]     Me.txtpassword.SetFocus[/FONT]
[FONT=Calibri]     Exit Sub[/FONT]
[FONT=Calibri] End If[/FONT]
 
[FONT=Calibri] If Me.txtpassword.Value = DLookup("strEmpPassword", "tblEmployees", _[/FONT]
[FONT=Calibri]         "[lngEmpID]=" & Me.cboEmployee.Value) Then[/FONT]
[FONT=Calibri]     lngMyEmpID = Me.cboEmployee.Value[/FONT]
[FONT=Calibri]     DoCmd.Close acForm, "frmDatabaseLogon", acSaveNo[/FONT]
[FONT=Calibri] Else[/FONT]
[FONT=Calibri]   MsgBox "Password Invalid. Please Try Again", vbOKOnly, _[/FONT]
[FONT=Calibri]         "Invalid Entry!"[/FONT]
[FONT=Calibri]     Me.txtpassword.SetFocus[/FONT]
[FONT=Calibri] End If[/FONT]
 
 
[FONT=Calibri] intLogonAttempts = intLogonAttempts + 1[/FONT]
 
[FONT=Calibri] If intLogonAttempts = 3 Then[/FONT]
[FONT=Calibri]   MsgBox "You do not have access to this database.Please contact admin.", _[/FONT]
[FONT=Calibri]            vbCritical, "Restricted Access!"[/FONT]
[FONT=Calibri]     Application.Quit[/FONT]
[FONT=Calibri] End If[/FONT]
[FONT=Calibri]End Sub[/FONT]

I appreciate your help
mithani

Hello Mithani,

On my db I do something similar to what your asking. Instead of closing the form, frmDatabaseLogon, set it's visible property to false, then all you have to do is refer to cboEmployee on frmDatabaseLogon, where ever you want the users name to show up.

HTH,
Shane
 
An easier way is to declare a public variable, say StrLoginName, in a module

Public StrLoginName As String

Then on your login screen, once the passwrod has been verified pass the users login name to the variable.

Then when you open a form you can do something like

Me.Caption = "Log In Name " & StrLoginName

David
 
An easier way is to declare a public variable, say StrLoginName, in a module
However, the more STABLE way is to do as Shane suggested. If you use global variables, you can be susceptible to those times where you may lose those (for example a runtime error). So, having the invisible form is more stable and ensures that you have what you need. I got that suggestion from Pat Hartman and have implemented that over the last couple of years and it has actually helped immensely.
 
However, the more STABLE way is to do as Shane suggested. If you use global variables, you can be susceptible to those times where you may lose those (for example a runtime error). So, having the invisible form is more stable and ensures that you have what you need. I got that suggestion from Pat Hartman and have implemented that over the last couple of years and it has actually helped immensely.

Thanks Bob, you took the words right out of my fingers.:) That has been my experience too. The first couple of years I used a global variable and had many times that it was lost. Using the invisible form, it has never lost the user name. It also helps to maintain a connection to the back end as well.

Shane
 
On my main menu I have a status bar (normally) and in the panels I store a various amount of data. such as User Name, Login Time, Account Status. See attachment, when in doubt I use this to get the necessary.
 

Attachments

On my main menu I have a status bar (normally) and in the panels I store a various amount of data. such as User Name, Login Time, Account Status. See attachment, when in doubt I use this to get the necessary.

Awesome looking interface, by the way! :)
 
Thanks guys. You all are very helpfull.
 
Re: MENU

On my main menu I have a status bar (normally) and in the panels I store a various amount of data. such as User Name, Login Time, Account Status. See attachment, when in doubt I use this to get the necessary.

Hi DCrake.

Your menu is awesome. Could you pleaes give me hint how this menu work. Thanks

Mithnai
 
i just saw something in the sample databases part of the forum, which possibly works the same way - haven't tried it out yet, but take a look.

by kharwar

(you have to hold down the shift key to see the code etc...)
 
Unfortunately I did not use the thread mentioned above. What I have is a set of ocx files that have varying functions. This one is an xpmenu simulator. The ocx's are expensive, there are about 82 in total and come as a package. Athough I do not have any connection with this supplier I do tend to promote them to people who want a very professional finish to there applications. Here is a link to their web site.

Here

I have been using them for over 3 years now and they have paid for themselves a few times over. Many times I read threads on how can I do this? Can Access do that? Well these can. I only wish I was on commission for the number of people I have directed to them.

David
 
Re: Cool Menus

Unfortunately I did not use the thread mentioned above. What I have is a set of ocx files that have varying functions. This one is an xpmenu simulator. The ocx's are expensive, there are about 82 in total and come as a package. Athough I do not have any connection with this supplier I do tend to promote them to people who want a very professional finish to there applications. Here is a link to their web site.

Here

I have been using them for over 3 years now and they have paid for themselves a few times over. Many times I read threads on how can I do this? Can Access do that? Well these can. I only wish I was on commission for the number of people I have directed to them.

David
I followed the link but a simple question.
How do i download the ocx files
 
You don't you have to either Try it, Buy It or upgrade It. As I said they are quite expensive but easily pay for themselves.

Also be aware that the license key and activation key is machine specific. You do however get 1 key for your base unit and one for your offline laptop (if you ask for it).

David
 

Users who are viewing this thread

Back
Top Bottom