By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,844 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,844 IT Pros & Developers. It's quick & easy.

Code Fails on second strSQL definition

P: 7
I am updating records in 2 tables, Employees and Projects with a new value for NAMEPHONE
The code fails on the second update in one sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdNewName_Click()
  2.     Dim conDatabase As DAO.Database
  3.     Dim strSQL As String
  4.  
  5. '  code which works beautifully
  6.     Set conDatabase = CurrentDb
  7.     strSQL = "UPDATE Projects SET Namephone= '" & Newname & "' WHERE NamePhone='" & oldname & "'"
  8.     conDatabase.Execute (strSQL)
  9.  
  10.  
  11.    ' and then I fail on line conDatabase.Execute (strSQL) !!!
  12.      strSQL = "UPDATE Employees SET Nampephone='" & Newname & "' Where NamePhone='" & oldname & "'"
  13.      conDatabase.Execute (strSQL)
  14.     
  15.  
  16.  
  17.     conDatabase.Close
  18.     Set conDatabase = Nothing
  19. End Sub
Apr 8 '13 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,335
It fails how? Is there an error message? What is it?
Apr 8 '13 #2

TheSmileyCoder
Expert Mod 100+
P: 2,321
Line 12, I believe you have a typo.
Nampephone should have been Namephone
Apr 8 '13 #3

NeoPa
Expert Mod 15k+
P: 31,307
Please check out Before Posting (VBA or SQL) Code before posting again.
Apr 9 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.