Results 1 to 8 of 8
  1. #1
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7

    import from excel to access

    hello everyone,

    i would like you to help me solving my next problem:

    i am trying to write a macro code (when i press a button in a form which i created) to import an excel file to an existing table (named " newtable")

    the code should include the following:
    1. a msg box that will pop-up and say "from which path to import the file"


    2. the name of the file will insert automataclly in a field (named " the file name") in the same form where the button is.

    also the excel file includes headers and i would like also to import them.

    thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Common topic. Did you search forum/web?

    Did you try the import wizard? Can save import specification and reference the specification with TransferSpreadsheet method.

    Importing headers to existing table does not make sense to me.
    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
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7
    Quote Originally Posted by June7 View Post
    Common topic. Did you search forum/web?

    Did you try the import wizard? Can save import specification and reference the specification with TransferSpreadsheet method.

    1Importing headers to existing table does not make sense to me.
    hey there,

    first of all, thanks for the quick response.
    altough there is a way to it by import wizard, i still want to write it using vba code. also, i don`t think that the import wizard can pop-up a dialog box (from which path in the computer to import)
    and i was wrong when i wrote "the excel file includes headers and i would like also to import them" - i want to import to existing table without the headers

    thanks
    Last edited by akinamon; 09-29-2014 at 02:28 PM. Reason: mistake

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Sorry my bad, the import specification is not used with TransferSpreadsheet, although TransferSpreadsheet is one method for importing.

    Consider DoCmd.RunSavedImportExport that runs an import specification built and saved with the wizard.

    Otherwise, require more complex VBA that opens and manipulates Excel objects.
    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.

  5. #5
    akinamon is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    7
    thanks,

    can u help me writing the complex VBA code?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    This is a common topic. Search forum and web. Attempt code. If you have issues, post specific question.

    If TransferSpreadsheet or RunSavedImportExport won't suit your situation, start with review of http://www.ehow.com/how_8156781_use-...el-access.html

    Regardless of which import method, if you want to allow user to select file path\name, need to use FilePicker dialog. That is different programming issue. Also a common topic.
    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.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

  8. #8
    gambit1430 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2014
    Posts
    4
    akinamon,

    ive tried it before....i used forms and vba control on this...and created a dummy table

    1. Create a form that will locate your xls file (ex...browse file form kinda staff)
    then put your code on the button...to import that excel to your dummy table (you will use vba on this, "docmd.transferspreadsheet"

    2. create queries to clean up your dummy table

    3. create query to append cleaned dummy table to your final table

    4. delete data on dummy table

    Follow June7's advise, check on google for the sample and codes..you can follow the steps given above and i hope this will guide you.

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

Similar Threads

  1. Replies: 10
    Last Post: 06-16-2014, 08:37 AM
  2. Import access query data into excel file, using excel vba
    By exceljockey in forum Import/Export Data
    Replies: 3
    Last Post: 11-15-2013, 02:36 PM
  3. Replies: 4
    Last Post: 12-17-2012, 01:21 PM
  4. Import excel to access
    By beha in forum Import/Export Data
    Replies: 8
    Last Post: 10-25-2011, 11:39 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