Log in

View Full Version : Update sql query in Access VBA - Shows error



ismailr
04-11-2013, 05:45 AM
Hi,

I am a beginner in writing VBA need your help to fix the issue that I am facing.
Your urgent response is highly appreciated.

I have two tables – Table A (Transactions) and Table B (Description_Code). Table A has many transaction with a field 'description'. Table B has a field 'Desc_code' for each 'description' in Table A.
I need to update the Table A Transaction code from Table B.

sqltxt = "UPDATE TRANSACTIONS A" &_
"SET A.DESC_CODE= " & _[/font]
"(SELECT B.DESC_CODE FROM DESCRIPTION_CODE B " & _
"WHERE B.DESCRIPTION = A.DESCRIPTION"

docmd.runsql(sqltxt)

During execution it shows an Error "Operation must use an updateable Please Advise. Thanking you in anticipation.

ismailr
04-12-2013, 11:32 PM
Hi
Can some one help me to fix the error?
Thanks.:friends:

mancubus
04-13-2013, 03:34 PM
im not an expert.

a little googling gave me this:
UPDATE TRANSACTIONS A
INNER JOIN DESCRIPTION_CODE B
ON A.DESC_CODE = B.DESC_CODE
SET A.DESCRIPTION = B.DESCRIPTION

orange
04-14-2013, 05:58 AM
Here are some possible causes of non -updateable query eror
http://allenbrowne.com/ser-61.html

You might also wish to review Normalization (http://en.wikipedia.org/wiki/Database_normalization) or this sample (http://databases.about.com/od/specificproducts/a/normalization.htm)

mohanvijay
04-15-2013, 12:05 AM
UPDATE Transactions a INNER JOIN Description_Code b ON a.description=b.description SET a.DESC_CODE = b.DESC_CODE