473,503 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Welcome "username" after log in

8 New Member
On my opening_form all that I have is:

Username1_label (which is a label)

Combo4 (which is a combo box that lists all the usernames from my table username_T)

and a Login Button, which allows you to navigate to the navigation_form in the database, if a username has been selected from the combo box (Combo4). It also closes the opening_form and automatically saves.If no username is selected from the combo box it prompts you with a MsgBox "please select a username".


Now, once you have navigated to the navigation_form, I would like for a friendly message to appear across the top of the form that says "Welcome "username"" with the "username" being the "username" selected on the previous form in the combo box.

Any help would be greatly appreciated.
Feb 4 '13 #1
11 7335
Rabbit
12,516 Recognized Expert Moderator MVP
You have a few options, leave the login form open so you can reference the control with the chosen user name, save it into a global variable and create a VBA function to return its value, or mark the record in the table and use a lookup to find who's logged in. The last option is viable only if the database is a standalone.
Feb 4 '13 #2
Seth Schrock
2,965 Recognized Expert Specialist
There are a couple of ways to do this depending on how you are storing the currently logged in user. The basic thing is that you need to get the username of the person logged in and assign it to a variable (for example strUser). If the control that holds the text "Welcome username is a label, then in your navigation_form's OnLoad event, make the label's caption be
Expand|Select|Wrap|Line Numbers
  1. lblWelcome.Caption = "Welcome " & strUser
Now how to populate strUser is another issue and requires knowledge of how you are storing the username of the person logged in. There are too many options, so I won't guess :)
Feb 4 '13 #3
jpmatthews
8 New Member
I really don't know how to store the name of the user logged in. I would like to be able to store the name of the user and also close the opening_form... Is that possible??
Feb 4 '13 #4
Seth Schrock
2,965 Recognized Expert Specialist
If you are needing to use the username to filter other records, then you could use tempvars. If not, you could use Rabbit's idea to leave the form open, but only long enough for the navigation form to get the value from the combo box and then let the navigation form close your login form.
Feb 4 '13 #5
jpmatthews
8 New Member
Alright I really appreciate it. thank you!
Feb 4 '13 #6
Seth Schrock
2,965 Recognized Expert Specialist
I just remembered, tempvars is new in Access 2007. If you are running Access 2003 or older, tempvars isn't available. I'm not positive about Access 2013, but I can't imagine that Microsoft would have gotten rid of it so quickly.
Feb 4 '13 #7
jpmatthews
8 New Member
Ok so now that I have gotten the tempvars to work. If I navigate to another form from my navigation_form (say a data entry form) and then navigate back to the navigation form the database has stopped storing the username and now it says Welcome #Name?. How can I get it to set that textbox to the value of the username once it has been changed. Does that make sense?
Feb 4 '13 #8
Seth Schrock
2,965 Recognized Expert Specialist
Post the code that sets the value of the tempvar and the code that sets the welcome text (be sure to use code tags, the [CODE/] button).

Tempvars aren't supposed to loose their value as long as the database stays open, which is the reason they were created (at least that is my understanding).
Feb 4 '13 #9
jpmatthews
8 New Member
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  
  3. If (Not IsNull(Combo4)) Then
  4.     TempVars.Add "Username1_Label", "(Combo4)"
  5.     DoCmd.OpenForm "Navigation_form", acNormal, "", "", , acNormal
  6.     Exit Sub
  7. End If
  8. Beep
  9. MsgBox "You must first select an employee.", vbOKOnly, ""
  10.  
  11. End Sub
That is the code that sets the TempVars


Expand|Select|Wrap|Line Numbers
  1. =[Forms]![OpeningForm]![username] & "!"
That is the code for the welcome text.

Now when you navigate to another form off the navigation_form, it closes the navigation form. I may just change that to keep the navigation_form open at all times and just closing the navigation_form if you want to sign out.
Feb 4 '13 #10
Seth Schrock
2,965 Recognized Expert Specialist
I usually leave my navigation form open, but that is up to you. If you want to be able to close it, then here is what you need to do. I'm going to assume the name txtUserName for your control. You can change it to whatever. In the navigation form's OnLoad event, put:
Expand|Select|Wrap|Line Numbers
  1. Me.txtUserName = Application.TempVars("Username1_Label").Value & "!"
Feb 4 '13 #11
NeoPa
32,557 Recognized Expert Moderator MVP
When you open a form from code (DoCmd.OpenForm()) there is a parameter called OpenArgs which is specifically for passing information into the new form. I suggest you put the user name value in the call then set the .Caption property of the label when the form opens (in the Form_Open() event procedure).
Feb 5 '13 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

5
12365
by: lsarg | last post by:
i've been trying forever to figure out a way to use a regular text link in place of a submit button at the bottom of this. can't get it. i'm just starting to learn php, so i'm stuck. any help at...
3
4534
by: Carpe Diem | last post by:
Hello I have an aspx page that loses Session("user") value after a few minutes even after I set <sessionState mode="InProc" cookieless="false" timeout="300"> in web.config and wrote function...
2
2242
by: Joebloggs | last post by:
Hi I am trying to do an ldap lookup. I can pick up the domain name in the standard format DOMAIN\USERNAME. The problem is the company I work for expects the query in the format DOMAIN:USERNAME....
1
1432
by: Kevin Gibbons | last post by:
If i did set cookie like this: FormsAuthentication.SetAuthCookie(username, False) How can i retrieve the username in another page ?
0
1395
by: Smokey Grindle | last post by:
I am using of course the login membership manager in asp.net 2.0, and am using the loginname control to display the current login name logged in, however, I'd rather display the users "actual name"...
0
2250
by: max.vit | last post by:
I am trying to retrieve the user name (network login) of clients running a local Access DB. We use Access 2000 / 2003 and Windows XP SP 2. I have used 2 different ways to access this information...
1
1829
by: incd | last post by:
Hello, I started out learning Perl today, but strict mode is just *weird* and not usefull? Why should I use it? What makes $Username different than the other variables? I was wondering, why I...
3
2275
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I use Session to save and pass values between pages, (please see the following). It works fine on my computer, but on the server, I launch the main page, wait for 20 minutes, and click a...
1
8617
by: xiaolim | last post by:
hi as shown in the source, i wanted to return to 'choice' in the 'switch' statement so that user can input their choices again after they chose the option. #include <iostream> #include...
4
7559
by: rotaryfreak | last post by:
so this has been blowing my mind for a few hours now and i have no idea what's going on. <form action="userLogin.php" method="get"> Username: <input type="text" name="userName" /><br/>...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.