text box is still empty when I set the default value

  • Thread starter Thread starter Jhonny Waller
  • Start date Start date
J

Jhonny Waller

I'm trying to put a textbox on one of my main forms and
use =CurrentUser() to display who the user is so I can see
who entered the record in my table but when I use that
function, the textbox is still empty. Can anyone tell me
how I can store the user's name in the table?? PLEASE!

Any help would be greatly appreciated.
 
I've been able to put an unbound textbox and set it's control source to
=CurrentUser() and that correctly displays the login name.

However, if you want to store that in a table, it's easier to just add a
field to each table
CreatedBy

Include this field in the recordsources for forms; you can put a textbox
bound to this field (hide the textbox if you like), and set its default
value to
=CurrentUser()

If you want to record who last modified the record, you'll need to use the
BeforeUpdate event for the form to set the value
 
-----Original Message-----
I've been able to put an unbound textbox and set it's control source to
=CurrentUser() and that correctly displays the login name.

However, if you want to store that in a table, it's easier to just add a
field to each table
CreatedBy

Include this field in the recordsources for forms; you can put a textbox
bound to this field (hide the textbox if you like), and set its default
value to
=CurrentUser()

If you want to record who last modified the record, you'll need to use the
BeforeUpdate event for the form to set the value
Thank you for your reply, however your second suggestion
is the way I'm trying to do it yet for some reason it
still doesnt dump the default value into my table. In
other words, I've created a bound textbox on my form
(given that at this point whether or not it's hidden
doesnt effect the data) and set the controll source
labeled "CreatedBy", set the default value of the textbox
to =CurrentUser() and nothing shows up in the table.
Please help!
 
Thank you for your reply, however your second suggestion
is the way I'm trying to do it yet for some reason it
still doesnt dump the default value into my table. In
other words, I've created a bound textbox on my form
(given that at this point whether or not it's hidden
doesnt effect the data) and set the controll source
labeled "CreatedBy", set the default value of the textbox
to =CurrentUser() and nothing shows up in the table.
Please help!

I'm assuming you mean you want to have a field that stores the current user
who *created* the record. If that's the case add a field to your table
(I'll call it CreatedBy). Add a textbox to your form that is bound to this
field. Set the default value of the textbox to =CurrentUser(). This will
put the current user's Access login name automatically into any *new*
records. It won't put it into existing records.

If you want to show both who created the record, and who last modified it,
then you would add another field (I'll call it ModifiedBy). Include
ModifiedBy in the recordsource for the form and in the BeforeUpdate event of
your form use
Me!ModifiedBy = CurrentUser()

This will be filled in only if/when a record is changed. Again it won't
fill in for existing records that haven't been modified.
 
Back
Top