Insert Value into Table

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Insert Value into Table

Post by burrina »

I need to insert the Environ(UserName into PCUserName field in tblUser

User avatar
HansV
Administrator
Posts: 78478
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Insert Value into Table

Post by HansV »

The following line will insert a new record in the table:

Code: Select all

CurrentDb.Execute "INSERT INTO tblUser (PCUserName) VALUES ('" & Environ("username") & "')", dbFailOnError
And this line will update the PCUserName field in the existing record(s):

Code: Select all

CurrentDb.Execute "UPDATE tblUser SET PCUserName='" & Environ("username") & "'", dbFailOnError
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Insert Value into Table

Post by burrina »

Thanks Hans. I'm hoping the rust comes off soon. Things I have forgotten how to do.
Appreciate it.