default value = current user logged on

icemonster

Registered User.
Local time
Today, 03:55
Joined
Jan 30, 2010
Messages
502
how do i set the current user to be the default value? e.g, i have a form that pulls the username of the computer to my database, how do i set it to be the default value of some of my tables?
 
how do i set the current user to be the default value? e.g, i have a form that pulls the username of the computer to my database, how do i set it to be the default value of some of my tables?

I normally use the Form's On Current and Before Update events to set default values for new records.

Code:
If Me.NewRecord Then
  Me.txtAddedBy =  gloVarNameHere
End If
* Note this is only an example for illustration. Not intended to suggest the use of Global Variables.
 
doesnt work. cause heres the deal with what i made, the tbl that holds what am trying to do is this

tblA has clientfield, stafffield, the staff field is looked up using tblemployee field, and the log in is also stored in the employee field, so how do i set it everytime i enter a record, who ever the current user is, becomes the default value, with northwind, i was able to do it because it had the temp variable thing. how do i do it here?
 
doesnt work. cause heres the deal with what i made, the tbl that holds what am trying to do is this

tblA has clientfield, stafffield, the staff field is looked up using tblemployee field, and the log in is also stored in the employee field, so how do i set it everytime i enter a record, who ever the current user is, becomes the default value, with northwind, i was able to do it because it had the temp variable thing. how do i do it here?

What I was answering was your original post. The method I describe will work for your original question and what you are describing now.

The basic concept of what I was suggesting will work for defaulting values for a new record. I use it a lot. I was not trying to suggest where the value can from. Thus the disclaimer NOTE below the code example.

I am not total clear what you really want to do. I am a little concerned that I still don't have the whole story of what you want to do.


After thinking about this some:

when you original said: "how do i set the current user to be the default value?"

Maybe what you really want to do is use the current user to look up the stafffield and use that as the default. Am I close?
 
Last edited:
Also, I hope you aren't using LOOKUPS at table level (Northwind does it and it is just plain WRONG and we've told the Access team about this many times).

See here for why lookups at table level are just plain bad.
 
it works now, but if i add a new field that has no lookup value, thing is, there is already an exisiting database for this that used the look up value from another table to fill the field, so how do i then use that value from another table which also retrieves the current user to be the default? because they are all related in my relationship window.

sorry to be so confusing.
 
it works now, but if i add a new field that has no lookup value, thing is, there is already an exisiting database for this that used the look up value from another table to fill the field, so how do i then use that value from another table which also retrieves the current user to be the default? because they are all related in my relationship window.

sorry to be so confusing.

What might help to eliminate a lot of the confusing, would be to post a sample of your database. Please include enough sample data that we can see the issue. Remember to remove any confidential data and replace with bogus/test data.
 

Users who are viewing this thread

Back
Top Bottom