Consulting

Results 1 to 5 of 5

Thread: Update sql query in Access VBA - Shows error

  1. #1
    VBAX Regular
    Joined
    Jun 2006
    Posts
    15
    Location

    Update sql query in Access VBA - Shows error

    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.

  2. #2
    VBAX Regular
    Joined
    Jun 2006
    Posts
    15
    Location
    Hi
    Can some one help me to fix the error?
    Thanks.

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    im not an expert.

    a little googling gave me this:
    [VBA]UPDATE TRANSACTIONS A
    INNER JOIN DESCRIPTION_CODE B
    ON A.DESC_CODE = B.DESC_CODE
    SET A.DESCRIPTION = B.DESCRIPTION[/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    257
    Location
    Here are some possible causes of non -updateable query eror
    http://allenbrowne.com/ser-61.html

    You might also wish to review Normalization or this sample

  5. #5
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    UPDATE Transactions a INNER JOIN Description_Code b ON a.description=b.description SET a.DESC_CODE = b.DESC_CODE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •