Results 1 to 3 of 3
  1. #1
    riagil is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Indonesian
    Posts
    2

    Smile Update table MS Access 2003

    Dear, Access Master
    I have 2 table tmpinduk and peminjaman:
    tmpinduk :


    ----------------------------------------------------------------
    induk | jdl_buku | pengarang | penerbit |jml_buku |status |
    ----------------------------------------------------------------
    144 | Cerita Rakyat | Iskandar | Bondan | 2 | 0 |
    155 | Naruto Komik | Masashi | Elexmedia | 0 | 0 |
    156 | Bleach Komik | Masashi | Elexmedia | 1 | 0 |
    177 | Teori Pembangunan | Mulyanto | UI-PRESS | 0 | 0 |
    179 | Ensiklopedia Hewan | - | Gramedia | 2 | 0 |
    180 | Ensiklopedia Tumbuhan | - | Gramedia | 1 | 0 |
    181 | Teknologi | Zoomkobe | Ganeca | 2 | 0 |
    182 | Baskeball Fundamental | Phil Jackson | Elexmedia | 1 | 0 |

    peminjaman :
    -----------------------------------------------------------------
    | mulai | kembali | nis |induk | jml_buku | denda | status |
    -----------------------------------------------------------------
    16/8/2010 | 18/8/2010 | 6325 | 155 | 3 | 0 | 0 |
    16/8/2010 | 18/8/2010 | 6325 | 156 | 2 | 0 | 0 |
    16/8/2010 | 18/8/2010 | 6464 | 144 | 1 | 0 | 0 |
    16/8/2010 | 18/8/2010 | 6464 | 177 | 1 | 0 | 0 |

    The question is, how to update tables on a column tmpinduk jml_buku like this, (tmpinduk.jml_buku + peminjaman.jml_buku), and I imagine the result is :

    tmpinduk :
    ----------------------------------------------------------------
    induk | jdl_buku | pengarang | penerbit |jml_buku |status |
    ----------------------------------------------------------------
    144 | Cerita Rakyat | Iskandar | Bondan | 3 | 0 |
    155 | Naruto Komik | Masashi | Elexmedia | 3 | 0 |
    156 | Bleach Komik | Masashi | Elexmedia | 3 | 0 |
    177 | Teori Pembangunan | Mulyanto | UI-PRESS | 1 | 0 |
    179 | Ensiklopedia Hewan | - | Gramedia | 2 | 0 |
    180 | Ensiklopedia Tumbuhan | - | Gramedia | 1 | 0 |
    181 | Teknologi | Zoomkobe | Ganeca | 2 | 0 |
    182 | Baskeball Fundamental | Phil Jackson | Elexmedia | 1 | 0 |

    I get an error message "syntax error (missing operator) in query expression, t.jml_buku + p.jml_buku from tmpinduk as t join peminjaman as p on p.induk = t.induk ",
    if I using this query :

    update t set t.jml_buku = t.jml_buku + p.jml_buku from tmpinduk as t join peminjaman as p on p.induk = t.induk
    in MsSQL Server this query have no problems...
    thanks before, for all your help.....

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    This is a small example that I have posted. I have used a Update Query to update tbltech which has a relation with table ccc. I have concatenated ccc.tname and ccc.tdetails and used it to update tbltech.tname.

    UPDATE tbltech INNER JOIN ccc ON tbltech.techid = ccc.techid SET tbltech.tname = [ccc].[tname]+" "+[ccc].[tdetails];

  3. #3
    riagil is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Location
    Indonesian
    Posts
    2

    Talking I have a mistake

    thank you maximus, but I have a problem with it..

    I try this :

    UPDATE peminjaman AS p INNER JOIN tmpinduk AS t ON p.induk=t.Induk
    SET t.jml_buku = t.jml_buku+p.jml_buku
    WHERE t.induk IN(select induk from peminjaman where nis=4646 and status=0);
    the result is wrong, this sql result : do you want to update 4 record?
    This not what I want, I want to update only record with nis=4646,,

    this : SET t.jml_buku = t.jml_buku+p.jml_buku
    is calculate all without see WHERE statement.

    I'm sorry with my English...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to update access table
    By ANDRE726 in forum Access
    Replies: 1
    Last Post: 01-27-2010, 04:26 AM
  2. Replies: 5
    Last Post: 01-05-2010, 10:22 PM
  3. Access 2003 - Creating Buttons from a Table
    By Speedy in forum Programming
    Replies: 2
    Last Post: 02-28-2009, 05:32 PM
  4. Replies: 0
    Last Post: 11-10-2008, 12:35 PM
  5. Replies: 1
    Last Post: 09-06-2006, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums