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

Using SQL to modify a record.

P: 4
Im still very new to access and probably way off track here.
But Im trying to create a SQL statement to overwrite an existing single record in access.
I tryed using this statement but it comes up with an error saying "query input must contain at least one table or query." ive been trying for a couple of hours and thats the error i get basiclly saying im way of track. Can anyone help please? The code i have so far is...

Expand|Select|Wrap|Line Numbers
  1. Dim mySQL As String
  2. mySQL = "INSERT INTO Journal ( Description )"
  3. mySQL = mySQL + " VALUES (Me![Comment])"
  4. mySQL = mySQL + " WHERE (((Journal.'Journal ID') = 3))"
  5. DoCmd.RunSQL mySQL
The tables name is Journal and the field is called Description and the record is 3 of the "journal ID"'s Autonumber. The data i want in there is from (Me![Comment]) Hope that all makes sense.
Thankyou for your help! :)
Dec 5 '08 #1
Share this Question
Share on Google+
3 Replies


mshmyob
Expert 100+
P: 903
Looking quickly at this I would put Journal ID in square brackets not single quotes.

You should get into the habit of never using spaces for naming conventions.

cheers,
Dec 5 '08 #2

P: 4
Thanks for that. But im thinking why it dosnt work is because you cant have a WHERE statement in a INSERT INTO statement

Can someone else please help me with this? Maybe with an UPDATE statement?
Trying my hardest but i just dont know enough about it. (and dont know how to learn it for that matter)
Thankyou!
Dec 9 '08 #3

Expert 100+
P: 1,287
"UPDATE Journal SET Description = """ & Comment & """ WHERE Journal_ID = 3"
Dec 9 '08 #4

Post your reply

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