New records linked to whoever is logged in

agrogers15

New Member
Joined
Sep 9, 2016
Messages
10
I am creating a database where a user logs in, and I need any records they create to auto populate a field with their userid. Thank you in advance!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Thanks Joe4! I think I'm getting closer to what I'm looking for. I want to use the CurrentUser() function but I'm not sure how to implement it. I've done some google searching but I only get very basic info. Could you write some sample code to put things into context?

Thanks!
 
Upvote 0
Both Environ("username") and CurrentUser() are built-in functionality.
Environ("username") uses the netowork ID and CurrentUser() uses the Access login, if you have set one up.

To see what each of them returns, just put a button on a Form, and place this VBA code on the ******* event of that button:
Code:
Private Sub Command24_Click()
    MsgBox "Network ID: " & Environ("username")
    MsgBox "Access ID: " & CurrentUser()
End Sub

The instructions in the link give you step-by-step instructions on how to get it to work. Just pick which the appropriate ID value you want to return, from those two options.
If you run into trouble, let us know which of the steps in the link is causing you issues.
 
Upvote 0

Forum statistics

Threads
1,221,792
Messages
6,161,997
Members
451,735
Latest member
Deasejm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top