Technically, domain\username is correct, since Regents\JohnSmith and Staff\
JohnSmith may not be the same user. But I think you don't want to see the
domain name in your table because everyone is on the same domain, so it's
redundant.
You have several alternatives. You could write a select query that uses vba
to only show the username, even though the domain name is stored in the table
with the username. This is probably the easiest.
If you want to keep SUSER_SNAME() as the default value, you could write a
trigger in Transact sql to fix it after the row is created. You could write
a stored procedure in Sql Server or a query in Access to update the column so
it removes the domain name in a specific row or in every row. You could
write a vba procedure in Access to update the column.
Or you could skip having SUSER_SNAME() as the default value. Write a vba
procedure that inserts the value of fOSUserName when the record is created.
Probably the form's after insert event would be best.
Chris
Microsoft MVP
SF wrote:
>Hi Chris,
>
>Thank you for your advice.
>
>My FE is connected to SQLServer 2005 back end. I modify my table to add a
>column 'Owner' and assigh SUSER_SNAME() as default value. I found that
>SUSER_SNAME() return Domain\Username which does not match value provided by
>fOSUserName() which return only username.
>
>How to store only username in the Owner column?
>
>SF
>
>> The code here will get the user's windows name:
>>
>[quoted text clipped - 21 lines]
>>>
>>>SF
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200807/1