Results 1 to 3 of 3
  1. #1
    djleggins is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    4

    Import Excel data with acImport

    Dear all,

    I am a newbie in Access 2007. I discovered the method

    DoCmd.TransferSpreadsheet acImport, _acSpreadsheetTypeExcel2007, _"ImportTest", _"Z:1996.xls", _True, _"P:Q"

    So how do I embed this. I would like to have a button in a form "Import Data" which activates the Import. Then, wenn the import is successfully completed, there should be a confirmation.

    Additionally, I do not want that the import overwrites data, it should just add the new data. The Excel sheet will always remain in the same structure. I will just add some data on a daily basis.



    Thanks.

    Last edited by djleggins; 11-19-2011 at 03:03 AM. Reason: typing error

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Create an onClick event for the import button.

    Create the button on a form. Then go to the property sheet for the button, go to the OnClick event and click on the ellipsis (,,,) at the end of the line. Select VBA code
    and the basic onclick subroutine will appear. Insert your code and you should be able to do the import. Where did the underscores in your code come from? They will probably create a compile error.

    Quote Originally Posted by djleggins View Post
    Dear all,

    I am a newbie in Access 2007. I discovered the method

    DoCmd.TransferSpreadsheet acImport, _acSpreadsheetTypeExcel2007, _"ImportTest", _"Z:1996.xls", _True, _"P:Q"

    So how do I embed this. I would like to have a button in a form "Import Data" which activates the Import. Then, wenn the import is successfully completed, there should be a confirmation.

    Additionally, I do not want that the import overwrites data, it should just add the new data. The Excel sheet will always remain in the same structure. I will just add some data on a daily basis.

    You don't specify what distinguishes new data. Is it date, record number...?
    Once you can create a query that selects the new data, then it is a matter of creating an append query to add it to the permanent table.
    Thanks.


  3. #3
    Join Date
    May 2010
    Posts
    339
    For more ideas check out Ken Snell's page.
    http://www.accessmvp.com/KDSnell/EXCEL_Import.htm

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

Similar Threads

  1. Import Data from Excel into Access
    By sauce1979 in forum Import/Export Data
    Replies: 2
    Last Post: 10-14-2011, 12:05 AM
  2. Import data from Excel
    By jhawkins49 in forum Import/Export Data
    Replies: 5
    Last Post: 08-23-2011, 02:05 PM
  3. Import data from Excel
    By mari_hitz in forum Import/Export Data
    Replies: 1
    Last Post: 06-13-2011, 07:34 AM
  4. Automate Import of Excel data
    By tpcervelo in forum Import/Export Data
    Replies: 2
    Last Post: 07-29-2010, 12:19 AM
  5. Using Import wizard to get Excel data
    By Jack Sheet in forum Import/Export Data
    Replies: 5
    Last Post: 07-16-2010, 09:44 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