Results 1 to 7 of 7
  1. #1
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55

    Complex Delete replace command or.....

    I need to be able to replace data that will be deleted if a customer is deleted. for example

    ID CustomerName CustomerPhone CustomerEquipment
    28 John Doe (530) 555-1212 RST3-2-11-4



    When the customer line is deleted it takes everything with it. Is there a way to make it so that the CustomerEquipment data is still saved or transfered to another table where it can be seen?

    Any help would be appreciated. Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Why delete customer? Why would you retain CustomerEquipment if Customer is deleted?

    Before the delete event could run an SQL INSERT action to save info to another table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55
    Quote Originally Posted by June7 View Post
    Why delete customer? Why would you retain CustomerEquipment if Customer is deleted?

    Before the delete event could run an SQL INSERT action to save info to another table.
    That's a good question and I should have addressed it in the beginning.
    My database maintains records based on the customer ID. When a customer is no longer with us there record gets deleted. Along with that goes the customerequipment field data.

    The customerequipment referes to facilities at my office. (RST3-02-11-04) would indicated that they are connected to equipment located at RST3, Shelf 2, Card 11, port 4.

    Once they are no longer a customer this equipment is available for use and I would like to be able to list Available equipment in a query calling for all RST not currently being used by a customer. If this value is deleted along with the customer I have no way of knowing that it exists.

    Im trying my luck at a "append query"
    I have one table that lists all of the equipment and another that lists equipment currently being used, but haven't figured out how to say only append records that don't currently match a specific equipment number, RST3-02-11-04 for example.

  4. #4
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55
    Quote Originally Posted by June7 View Post
    Why delete customer? Why would you retain CustomerEquipment if Customer is deleted?

    Before the delete event could run an SQL INSERT action to save info to another table.
    Actually, the append query isn't going to work anyway. Problem....
    ID Name Address Cable Pair Equipment Number
    234 BOB 123 main st 234 RST3-02-04-06

    The only thing I can actually get rid of is the customer ID. Everything else I need to maintain.

    Boy, I tell ya what.... this whole database creation thing realy makes you think ahead. Too bad I haven't caught on yet.

    That being said.... Is there a way to delete the record but maintain "MOST" of the data in a new row?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Wouldn't the name and address info also go with the customer ID, leaving only the EquipmentNumber?

    Problem is your data structure is not normalized. Review this http://forums.aspfree.com/microsoft-...es-208217.html

    It is seldom a good idea to delete records. What if the customer comes back? Wouldn't you want that history?

    You should have a table for equipment and show in this table where the equipment is checked out to. A field with customerID would do. If you want history of where equipment has been, have a junction table.
    tblCustomerEquipment
    EquipmentID
    CustomerID
    DateAssigned
    DateReturned

    Eliminates need to delete customer or copy equipment between tables.

    There are probably existing template databases that fit your needs. The Lending Library is one that might be adapted.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    danbo is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    55
    Quote Originally Posted by June7 View Post
    Problem is your data structure is not normalized.

    It is seldom a good idea to delete records. What if the customer comes back? Wouldn't you want that history? Better is to have a Yes/No field to indicated status (active or inactive). Use that field in queries to exclude the inactive records. You can make a returning customer active by simply changing this value. Much easier than the delete and copy data you are trying.

    You should have a table for equipment and show in this table where the equipment is checked out to. A field with customerID would do. If you want history of where equipment has been, have a junction table.
    tblCustomerEquipment
    EquipmentID
    CustomerID
    DateAssigned
    DateReturned

    Eliminates need to delete customer or copy equipment between tables.

    There are probably existing template databases that fit your needs. The Lending Library is one that might be adapted.
    I agree with you on deleting records and was just looking to see what other avenues I could explore. I'm sure it's not normal, lol this is my first database and I have no clue what I'm doing, but..... it "seems" to be working except for this one last glitch. I guess the best thing I can do at this point would be to manually go into the database records, copy that equipment and paste it into a new record. and delete the equipment from the customers current record. Seems like a lot to have to do though.

    thanks

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Best thing is to properly design the data structure. Look at my other post again, did some edits as you were posting yours.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Trying to Delete record using delete query
    By MooseOTL in forum Access
    Replies: 13
    Last Post: 10-04-2011, 02:30 AM
  2. Error handling for delete record command
    By jobrien4 in forum Access
    Replies: 2
    Last Post: 09-16-2011, 11:00 AM
  3. Replace "
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 05-10-2011, 07:09 AM
  4. Duplicate query with complex delete function
    By rushforth in forum Queries
    Replies: 9
    Last Post: 08-20-2010, 01:21 AM
  5. Command button help - delete record
    By Zukster in forum Forms
    Replies: 0
    Last Post: 08-27-2009, 08:47 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