Results 1 to 2 of 2
  1. #1
    ejh is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    4

    deleting records that have no relation

    I have two tables, one for jobs and one for clients. I have a one-to-many relationship, so one client can have many jobs. Due to a problem with data entry, I have some client records that have no job associated with them. I need to delete these records. I am very new to access and this isn't supposed to be my job, so I don't really know how to do this.

    How do I do this?

  2. #2
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    1. Create a new Yes/No Field with the fieldname FLAG in the Jobs Table.
    2. Create an Update Query like the sample SQL given below by linking them both on the Key fields:


    Code:
    UPDATE Clients INNER JOIN Jobs ON Clients.ID = Jobs.IDX SET Jobs.FLAG = True;
    3. Run the Update Query to mark the FLAG field for matching records of both tables.
    4. This action will leave the records in the Jobs table which have no corresponding Clients records.
    5. Create a DELETE Query on Jobs Table to select and delete the unmarked records.

    Code:
    DELETE Jobs.*, Jobs.FLAG
    FROM Jobs
    WHERE (((Jobs.FLAG)=False));

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

Similar Threads

  1. Quick question about deleting records
    By pinecrest515 in forum Queries
    Replies: 3
    Last Post: 12-14-2010, 10:58 AM
  2. Prevent Users from Deleting Records
    By DocOrganizer in forum Access
    Replies: 15
    Last Post: 11-30-2010, 02:57 PM
  3. deleting records
    By radicalrik in forum Queries
    Replies: 2
    Last Post: 07-14-2010, 03:10 PM
  4. deleting records off a subform
    By jamin14 in forum Programming
    Replies: 10
    Last Post: 04-22-2010, 08:47 PM
  5. Problem Deleting Records with ADO
    By bdicasa in forum Programming
    Replies: 0
    Last Post: 08-21-2008, 09:27 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