current user name

icemonster

Registered User.
Local time
Yesterday, 18:22
Joined
Jan 30, 2010
Messages
502
hi

i am currently had someone make me a log in that utilizes the windows log on as the log in for the database, the things is, before i did that, i had a very simple log in form, now that it is set, i was wondering, because the log in is still based on a table, how do i set my current log in as a temp variable? because i had a table that lets you type everything that goes on with a particular subject, now with that i want it to be automatic in inputting who the current user is. how do i do that?
 
If you only need it temporarily (during this open session of the database), you can store it in a global variable and grab it as needed. Declare your global variable as public and put it in a module.

If you need to remember it between sessions (after you've exited and re-entered the database), you can put it in the registry. See SaveSetting() and GetSetting() in help.
 
well i need it to get stored. how do i do that?
 
Please re-read my post and answer the implied question: how long do you need it stored?

Then look up the topic I point to for each option (global variable vs. storing it in the registry). If it is short term (just during this session), store it in a global variable in VBA (see VBA help). If it is over multiple sessions, use VBA functions SaveSetting() and GetSetting() to write to and read from the registry (see VBA help).

When you have a specific question, let us know.
 
sorry.

well i have a table that says employeeid, what i want is, for the current user, to be stored in the employeeid, so what am trying to says is, everytime i enter a new record, whoever is logged in will get stored on that table.

so i want it stored indefinitely a
 
You need to look at update or insert queries in Access help. Then you can run a query in VBA (or possibly in a macro). You can get the actual SQL for a query from the SQL view in the Query Builder. Your code would look something like (warning: AIR CODE):

Code:
DoCmd.RunSQL "update whatevertableitisyouhaveemployeeidin set employeeid = '" & whatevercontrolyouregettingtheidfrom & "' where whateverconditionsyouneedtocheckfor;"
or
Code:
DoCmd.RunSQL "insert into whatevertableitisyouhaveemployeeidin (employeeid) VALUES ('" & whatevercontrolyouregettingtheidfrom & "');"
 

Users who are viewing this thread

Back
Top Bottom