Home Forums Microsoft Access Microsoft Access Update Field to current logged in user ID with new record command button RE: Update Field to current logged in user ID with new record command button

  • kwoznica (7/17/2013)


    Thanks for the suggestions but I have not been successful.

    I used Environ("UserName"), suser_sname(), and select system_user to populate the value in the text box on the form.

    I am setting this in the Control Source of the Textbox Data Properties. After doing so it returns a value of #Name? or Admin. I am no logged in as either of these ID's.

    ....

    If you are going to let SQL Server do the work for you, then you need to set the Default Value in the table definition in SQL Server, not in an Access text box. The T-SQL for doing that is:

    ALTER TABLE [dbo].[YourTable] ADD CONSTRAINT [DF_YourTable_strWhoEdited] DEFAULT (suser_sname()) FOR [strWhoEdited]

    However we usually use the table designer SSMS to set such things as default values, Null or Not Null, etc.

    Wendell

    Colorado, USA

    Wendell
    Colorful Colorado
    You can't see the view if you don't climb the mountain!