Results 1 to 2 of 2
  1. #1
    kowen091010 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    14

    Import Button

    Could some please show me what the code would be to create a command to import and append a table?

    Name: Form1
    Drive Location:J:\BYY Goal 7 - 2011
    Excel File Name: Current Customers
    Excel File Type: Macro-Enabled Worksheet


    Table 1 - tblaggregateddata - need to add to table
    Table 2 - Current Customers - need to replace all information in this table with imported data.
    Command Button - Command6 & Command8

    I have been trying to write the proper code to get these to buttons to automatically import the data. Unfortunately everything I have tried has failed. Above are the names from my Access Database and Computer Drive. Could someone please help me write the proper code or figure out a macro in order to add a Command Button?

    Please and Thank you!!!

  2. #2
    dreday's Avatar
    dreday is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58
    Sure, inside the VBA for each button place the appropriate format of the code below:

    docmd
    .TransferSpreadsheet(TransferType, SpreadsheetType, TableName, FileName, HasFieldNames, Range, UseOA)


    The options are explained here and intellisense will help you through it too:
    http://msdn.microsoft.com/en-us/libr...ice.12%29.aspx

    Also, for current customers, since you want to replace all the info in the table just run a quick sql command before the transferspreadsheet command:

    Docmd.RunSQL "Delete * from [Current Customers]"

    That will wipe out all the data already in the table before the fresh data are imported.

    Hope this helps

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

Similar Threads

  1. Error Import Command Button
    By kowen091010 in forum Access
    Replies: 4
    Last Post: 12-15-2011, 07:56 AM
  2. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  3. example of txt import
    By liebor in forum Import/Export Data
    Replies: 3
    Last Post: 03-09-2011, 09:08 AM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 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