Automatically Fill Field Based On User ID

Tor_Fey

Registered User.
Local time
Today, 09:03
Joined
Feb 8, 2013
Messages
121
Good Morning All;

I have a table called tbl_post_staff, within this table I have an id number (autonumber), user id (text) and user full name(text). Then I have a form called ec_main with a combobox linked to tbl_post_staff, but stores its value in a field called officer_is in a table called tbl_extensions. also on the ec_main form is a text box that displays current user.

What I am trying to do is; on my form ec_main; default the combobox (Called officeris) to the staff full name based on there userid that is logged in. how can I do this? :banghead:

Kind Regards
Tor Fey
 
Something like: Of course adjust to your needs.
PHP:
Me.SomeCombobox = Environ("UserName")

HTH
 
Hi Burrina;

Thanks for the reply, I have added this to the onload event of my form, although it works, it only shows the user id, is there a way to convert this to the user full name by comparing the userid in the tbl_post_staff and changing it?

for example: if user id = jblog then officeris = Joe Blogs

Kind Regards
Tor Fey
 
Do you have the full name of the user stored in your table?
 
Yes;

the table structure is as follows: post_staff_id, post_staff_officer and post_staff_user

The field "post_staff_officer" contains the user full name

Regards
Tor Fey
 
Apologies; the field "post_staff_user" is the user id

Regards
Tor Fey
 
Try something like this: Unsure of your setup. Here is an example:
PHP:
Me.txtwhoareyou = DLookup("[UserID]", "tblUserSecurity_Sec", "[UserID]='" & Me.txtuserid.Value & "'")
 
Can't see to make this work, here is what I have onload event:

Me.currentuser = DLookup("[post_staff_user]", "tbl_post_staff", "[post_staff_officer]='" & Me.officeris.Value & "'")
 
Last edited:
Something like this would be good:

if me.useris = jblog then me.officeris = Joe Blogs

Can I just do it on form load with VBA? :banghead:
 
I still don't know how you are trying to get this information. Normally it is trapped when you log into the database. Is this your setup? Your syntax is all over the place?

You can only retrieve what is stored! UserName will not give you what is stored in your table.
 
Good Morning Burrina;

Sorry about this, but I am new to access and have inherited a lot of old database created using vba only.

I have created a table called "tbl_post_staff" in the database which contains the network id of the user (e.g. jblog) I have called my field for the network id "post_staff_user_id", also within the table I have created I have another field called "post_staff_officer" which I have put the users full name in, I also have a autonumber field set for my record id called “post_staff_id” which is just sequential when I add a new user.

So what I would like to do is the following:

When the unbound text box field called "useris" is set as “=currentuser()” shows the id of the logged on user, I would like to make the field “officeris” (Combobox which contains the network user id’s, full user names and looks up from the “tbl_table_staff” table) on my “EC_main” form; look at the logged on user and then show the default user name as the users full name (e.g. Joe Blogs)

Kind Regards
Tor Fey
 
Good Morning All;

I have a table called tbl_post_staff, within this table I have an id number (autonumber), user id (text) and user full name(text). Then I have a form called ec_main with a combobox linked to tbl_post_staff, but stores its value in a field called officer_is in a table called tbl_extensions. also on the ec_main form is a text box that displays current user.

What I am trying to do is; on my form ec_main; default the combobox (Called officeris) to the staff full name based on there userid that is logged in. how can I do this? :banghead:

Kind Regards
Tor Fey

Hello,
I do this as well... you need to have a login screen to set the temp variables first. so that when the form loads it knows who is using it. and on the on load or after update of a control event procedure just put. me.
officeris=[TempVars!][LoginID] or something like that.

Login form tutorial is on youtube.
watch?v=sWsTwYuWc1o

Though it has its issues with the password thingy, its a good start,


 
Resolved:

Added 3 fields to form frm_EC_Main as follows:

· Useris – unbound combobox linked to tbl_post staff bound to column 2; with a default value of =currentuser() in the following way: SELECT tbl_post_staff.post_staff_id, tbl_post_staff.post_staff_user_id, tbl_post_staff.post_staff_officer FROM tbl_post_staff ORDER BY [post_staff_id];

· Officeris – unbound text box with a control source as follows: =useris.column(2)

· Ecofficeris – bound text box to a field in tbl_EC_errors, populated by a form onload event as follows: DoCmd.Maximize, Me!ecofficeris = Me!officeris, DoCmd.Save, DoCmd.Requery, DoCmd.Save


This has finally achieved my desired result :D
Kind Regards
Tor Fey
 

Users who are viewing this thread

Back
Top Bottom