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.
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.
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 - 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 :)
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??
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.
Alright I really appreciate it. thank you!
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.
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?
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).
- Private Sub Command0_Click()
-
-
If (Not IsNull(Combo4)) Then
-
TempVars.Add "Username1_Label", "(Combo4)"
-
DoCmd.OpenForm "Navigation_form", acNormal, "", "", , acNormal
-
Exit Sub
-
End If
-
Beep
-
MsgBox "You must first select an employee.", vbOKOnly, ""
-
-
End Sub
That is the code that sets the TempVars - =[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.
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: - Me.txtUserName = Application.TempVars("Username1_Label").Value & "!"
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).
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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....
|
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 ?
|
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"...
| |
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...
|
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...
|
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...
|
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...
|
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/>...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
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...
| |