Insert and Update Criteria

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

Insert and Update Criteria

Post by burrina »

I am confused again with this syntax. I need a insert and a update statement. Here is my attempts

Code: Select all

DoCmd.RunSQL "Insert Into tblUsers (txtAddAlias) Value & (Me."ComputerLoginName") & "'" , dbFailOnError
 
CurrentDb.Execute "UPDATE tblUsers SET Alias='" & (Me."txtAddAlias") & (Me."ComputerLoginName") & "'", dbFailOnError  
 

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

Re: Insert and Update Criteria

Post by HansV »

1) In an append query (INSERT INTO), you need to use Values, not Value, even if you only insert one value.
2) Don't use quotes around control names: change Me."ComputerLoginName" to Me.ComputerLoginName etc.
3) dbFailOnError is only valid for CurrentDb.Execute, not for DoCmd.RunSQL.

Do you have a specific reason for using DoCmd.RunSQL for one, and CurrentDb.Execute for the other? Why not use one of them for both lines?
Best wishes,
Hans

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

Re: Insert and Update Criteria

Post by burrina »

No, just trying to figure things out is all. Too much coding, brain is fried.

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

Re: Insert and Update Criteria

Post by burrina »

Thank You