Results 1 to 5 of 5

Thread: Importing data from Excel into Access[Resolved]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Angry Importing data from Excel into Access[Resolved]

    Dear All,


    I have an Excel sheet. It contains two coulums of data(for example employee# and name).

    I have to import data from this excel sheet into Access table.

    How can I do this.

    Plz Guide.
    Last edited by engineer; Oct 9th, 2005 at 03:28 PM.
    software engineer

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Importing data from Excel into Access

    Using VB you can automate MS Access so you can import data directly into it - set references to MS Access x.x and run this sample code:
    VB Code:
    1. Private Sub ImportExcelSheet(strMdbPath As String, strExcelPath As String, strSheetName As String)
    2. '==================================================================================================
    3. Dim AccessDB As Access.Application
    4.  
    5.     Screen.MousePointer = vbHourglass
    6.     Set AccessDB = New Access.Application
    7.     AccessDB.OpenCurrentDatabase strMdbPath
    8.     AccessDB.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
    9.                                        strSheetName, strExcelPath
    10.     AccessDB.DoCmd.TransferDatabase acExport
    11.     AccessDB.Quit acQuitSaveNone
    12.     Set AccessDB = Nothing
    13.     Screen.MousePointer = vbDefault
    14.  
    15. End Sub
    16.  
    17. 'usage:
    18. Private Sub Command1_Click()
    19.    
    20.     ImportExcelSheet App.Path & "\nwind.mdb", _
    21.                      App.Path & "\receipts.xls", _
    22.                      "Receipts"
    23.  
    24. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Angry Re: Importing data from Excel into Access

    Thanks RhinoBull.

    I am gona try this.
    software engineer

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Importing data from Excel into Access

    Actually if you just open the Access db and either run the Transfer Spreadsheet menu command or the DoCmd.TransferSpreadsheet in a module you dont need to complicate the issue unless you need it like RB posted, to execute from a VB program.

    Moved from Classic VB forum.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    237

    Re: Importing data from Excel into Access

    Thanks for the great help.
    software engineer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width