|
-
Oct 7th, 2005, 03:31 PM
#1
Thread Starter
Addicted Member
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
-
Oct 7th, 2005, 03:48 PM
#2
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:
Private Sub ImportExcelSheet(strMdbPath As String, strExcelPath As String, strSheetName As String)
'==================================================================================================
Dim AccessDB As Access.Application
Screen.MousePointer = vbHourglass
Set AccessDB = New Access.Application
AccessDB.OpenCurrentDatabase strMdbPath
AccessDB.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strSheetName, strExcelPath
AccessDB.DoCmd.TransferDatabase acExport
AccessDB.Quit acQuitSaveNone
Set AccessDB = Nothing
Screen.MousePointer = vbDefault
End Sub
'usage:
Private Sub Command1_Click()
ImportExcelSheet App.Path & "\nwind.mdb", _
App.Path & "\receipts.xls", _
"Receipts"
End Sub
-
Oct 7th, 2005, 03:50 PM
#3
Thread Starter
Addicted Member
Re: Importing data from Excel into Access
Thanks RhinoBull.
I am gona try this.
-
Oct 7th, 2005, 03:52 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Oct 9th, 2005, 03:27 PM
#5
Thread Starter
Addicted Member
Re: Importing data from Excel into Access
Thanks for the great help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|