Solved

Excel tables to MSAccess

Posted on 2013-11-06
5
420 Views
Last Modified: 2013-11-27
Hi all,

Grateful if anyone could show me how to convert the data in an Excel workbook with has three worksheets into an MSAccess table from MSAccess.

Preferably I would like to know if it can be done using vba.

I am attaching my sample excel file so it can be seen.

Thanks
tablesforAccess.xls
0
Comment
Question by:PipMic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:PipMic
ID: 39628067
my apologies the heading "Date" is missing in each of the tables...
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39628075
yes it can be done using vba,
using
docmd.transferspreadsheet acimport,8, "tableX", "c:\foldername\yourexcel.xls",true,"sheet1!"


now give more specific information on how you like the information from the excel file to look like in   access table?


this vba commands will import the content of the Excel to 3 tables, table1,table2,table3


DoCmd.TransferSpreadsheet acImport, 8, "table1", CurrentProject.Path & "\tablesforAccess.xls", True, "sheet1!"
DoCmd.TransferSpreadsheet acImport, 8, "table2", CurrentProject.Path & "\tablesforAccess.xls", True, "sheet2!"
DoCmd.TransferSpreadsheet acImport, 8, "table3", CurrentProject.Path & "\tablesforAccess.xls", True, "sheet3!"


if you want combine the three tables to one, run a make table query like this

Select A.*  Into FinalTable
 from
(
SELECT table1.F1, table1.[1], table1.[2], table1.[3], table1.[4], table1.[5]
FROM table1
Union All
SELECT table2.F1, table2.[6], table2.[7], table2.[8], table2.[9], table2.[10]
FROM table2
Union All
SELECT table3.F1, table3.[11], table3.[12], table3.[13], table3.[14], table3.[15]
FROM table3
) as A
0
 

Author Comment

by:PipMic
ID: 39630478
Tried this one line but no luck:

DoCmd.TransferSpreadsheet acImport, 8, "table1", "c:\1\tablesforAccess.xls", True, "sheet1!"

Compile error
Invalid outside procedure
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 500 total points
ID: 39630779
where did you place the code?

try placing the code in the click event of a command button.

private sub command0_click()

DoCmd.TransferSpreadsheet acImport, 8, "table1", "c:\1\tablesforAccess.xls", True, "sheet1!"


end sub
0
 

Author Closing Comment

by:PipMic
ID: 39681191
very good
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question