473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Autopopulate a field in a form based on what user is logged in

1
I've created an access database using access 2007 for one of the teams I work with and I'm fairly new to access so would like some help. The database is being used to log jobs for engineers so I have a login system where a user selects their name from a drop down and enters their password, and depending on their access levels they get directed to their own user menus etc. Now what I would like is once the user has logged in their name to auto-populate in the job sheet form which I've created and in the form is a field labelled user, how do I get the user who has logged in their name to just auto populate in the field once they have accessed it.
Jul 22 '15 #1
2 1169
jimatqsi
1,271 Expert 1GB
One way to accomplish that is keep the form with the login dropdown open. Make it invisible if you like but don't let it be closed. Then, in the OnLoad event of the job sheet form you can put something like this:
Expand|Select|Wrap|Line Numbers
  1. me.user=forms!loginformname!user_cbo
Change loginformname to the name of the form with the dropdown used for logging in, and user_cbo to the name of the dropdown combo box and that should work.

Jim
Jul 22 '15 #2
jforbes
1,107 Expert 1GB
What Jimatqsi has posted would definitely work.

You could take it a little further if you like and when the user clicks whatever button they click to login, store the User Name/ID into a Global Variable.
Expand|Select|Wrap|Line Numbers
  1. Global gUserID As String
You could then create a function, to return the UserID.
Expand|Select|Wrap|Line Numbers
  1. Public Function getUserID() As String
  2.     getUserID= gUserID 
  3. End Function
Lastly, on Forms where you want to fill in the User as the Default, set the Default Property of the User Field to the new function.
Expand|Select|Wrap|Line Numbers
  1. =getUserID()
Jul 22 '15 #3

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

Similar topics

5
by: Raffi | last post by:
Hi folks, I'm new to JavaScript and need some help. I have a form with a select field. Depending on what is selected in this field, I want to display or not display another select field. For...
3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
1
by: jon.ingram | last post by:
I have a main menu that contains 2 drop down boxes. Drop down 1 contains: BSL USL Drop down 2 contains: 1 2 3
2
by: Rudy Mark | last post by:
I have used form based authentication. for each page_load I am using "User.Identity.IsAuthenticated" to authenticate the user. My question is , when I click on the refesh button, application takes...
6
by: Frank Walsh | last post by:
Can anyone tell me if this is possible in asp.net, I want to use form-based authentication to authenticate my users, however a employee of the company is attempting to be logged in as administrator...
4
by: Deus402 | last post by:
Here is my table design: tblEmployers EmployerID autonum (primary key) EmployerName text tblLocations LocationID autonum (primary key) EmployerID longint (foreign key) LocationAdress text
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
5
by: iChappy | last post by:
I have a query based off of two fields in an Access form: Fiscal Week (user manual inputs #) & Fiscal Year (combo box defaulted to current year however may select other years) The query is a...
1
by: SKODA | last post by:
Hi, I am a beginner to MS ACCESS. I have 100+ tickers and each has a table. I would like to retrieve data from a specified table based on user input. My trials: I am unable to create a form that...
22
by: HiGu | last post by:
I have a form which displays a column named A_JobNo(e.g. value: "E1Y4000") from a table in a textbox.There is an input mask applied to this texbox: >L\-0A\-0000 which makes the value appear like...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.