Results 1 to 6 of 6
  1. #1
    AlexBen is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2021
    Posts
    10

    delete the whole table


    Good day! Beside clicking DEL from the keyboard, is there a way (code) to delete the whole table? not just the content. It is when am importing data from excel, there's a dump table created. Thanks in advance!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    currentdb.execute "Delete * From YOURTABLENAME_HERE ;" <<deletes records

    currentdb.execute "DROP TABLE table_name;" <<<deletes table and data

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by orange View Post
    currentdb.execute "Delete * From YOURTABLENAME_HERE ;" <<deletes records

    currentdb.execute "DROP TABLE table_name;" <<<deletes table and data
    @orange
    Why the delete, when the drop gets rid of everything in one go?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Doesn't repeatedly deleting and recreating the table cause db bloat? At least I'm guessing that the import from Excel is going to happen over an over again. When importing, you have the option to overwrite the whole table without deleting or append to it, no? Have to confess I have not done much of that so I'm asking more than suggesting a route to take.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    When I created a small DB for a UK bank I was working at, I had to import a stupidly large Excel sheet (for what we needed at least), and find what we needed.
    Now I realise linking to a static named workbook would have been better, and failing that a side DB for any imports. The DB bloated regularly.

    Alas, that knowledge is now moot, as I retired.

    That is where Foxpro comes into it's own, as well as the much better speed, the ZAP command.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Paul,

    I provided both Delete and Drop more for info/instruction since the OP doesn't seem to be aware of either.
    Regarding other points in the thread -- bloat etc, I think we need to know more about the processes involved and context. Often wise to do C&R and bkup during periods of multiple loading/processing/deleting.

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

Similar Threads

  1. Replies: 10
    Last Post: 12-29-2019, 01:32 AM
  2. Replies: 11
    Last Post: 09-30-2018, 08:55 PM
  3. Delete does not delete records in evey table
    By LaughingBull in forum Access
    Replies: 5
    Last Post: 09-01-2015, 04:05 PM
  4. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  5. Replies: 11
    Last Post: 03-30-2011, 01:08 PM

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