Results 1 to 4 of 4
  1. #1
    rameshjctr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2016
    Posts
    16

    deleting from multiple tables

    friends

    i am having 3 tables USERS,PERSONAL,SAL having common PEN as id. now i want to delete a record from these tables using a DELETE command button. i have coded on the clicked event
    dim str as string
    dim user as long
    user = Text1(where i have to enter the PEN to delete)
    str = "delete A.* , B.* , C.* FROM USERS AS A , PERSONAL AS B , SAL AS C WHERE A.PEN = B.PEN AND B.PEN = C.PEN AND A.PEN = user;"
    docmd.runsql str

    when i run it it shows a syntax error "Runtime error:3086. Could not delete from specified tables".

    table users having fields PEN, ENAME
    table personal having fields PEN, ENAME,ADDR
    table sal having fields PEN,BASIC,DA,HRA

    I want to delete ALL RECORDS FROM THESE TABLES DEPENDING UPON A PARTICULAR PEN VALUE

    THANKING YOU



    RAMESH

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You need 3 queries, not 1.
    delete from each table individually.

  3. #3
    rameshjctr is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2016
    Posts
    16
    so i have to code 3 delete queries individually. ok friend thank you.

    Ramesh J

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    How are the tables related?
    Please show your relationships window as a jpg.

    Depending on relationships, and enforced referential integrity, if you delete a parent table, then children would be deleted.
    But it depends on your table structure.
    Good luck.

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

Similar Threads

  1. Deleting old tables
    By crowegreg in forum Programming
    Replies: 1
    Last Post: 09-06-2013, 11:03 AM
  2. Deleting linked tables
    By hertfordkc in forum Database Design
    Replies: 8
    Last Post: 09-20-2011, 02:58 PM
  3. Deleting Error Tables Automatically
    By mchadwick in forum Access
    Replies: 8
    Last Post: 09-06-2011, 12:40 PM
  4. Deleting error tables
    By bcurrey in forum Programming
    Replies: 3
    Last Post: 08-23-2011, 05:39 PM
  5. Deleting Tables With Wildcard?
    By orcinus in forum Programming
    Replies: 2
    Last Post: 06-20-2011, 10: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