Help with importing data, VB code to delete old table and replace with the new import.

Posted on 2007-10-10
Last Modified: 2013-11-29
Hi Experts,

Today I would like to know how I could write a little bit of code so when you push a button in MS Access on a form, it will...

1) Delete the a table called "SSL"
2) Import an excel file from, lets say in the root (C:\>SSL.xls )  into a table to replace the 1 we've just deleted called "SSL"
3) I'd like the database to keep all it's relationships.

I need to do this because the information is constantly being updated.  I'd like to use the link to *.xls but se MS Access isn't so great at guessing mulitple assigned fields, import is the easiest method I think.

Thanks Everybody
Question by:squidlings
    1 Comment
    LVL 77

    Accepted Solution

    If you don't want to link then why not just delete the existing data and import the new data.

    query to delete...

    Delete * from ssl

    command to import:

    docmd.TransferSpreadsheet acImport,acSpreadsheetTypeExcel9,"SSL","c:\ssl.xls",True

    You don't have to worry abolut realtionships in this case.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now