473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Importing Large Numbers of Tables from Text files.

Good Day,

I have been having this issue for quite a long time, and have yet to find an easy/elegant solution.

I am trying to create tables in an Access database.

I have these tables as CSV files, with the Header as the first line.

I have approximately 1000 tables.

Importing these tables by hand is a pain.

I figured there must be a simple way to import all tables in a folder using a Macro.

I created a form with a button that runs the following Sub:
Private Sub Command0_Click()
Dim InputDir, ImportFile As String, tblName As String
Dim InputMsg As String

InputMsg = "Type the pathname of the folder that contains "
InputMsg = InputMsg & "the files you want to import."
InputDir = InputBox(InputMsg)
' Change the file extension on the next line for the
' type of file you want to import.
ImportFile = Dir(InputDir & "\*.txt")

Do While Len(ImportFile) > 0
' Use the import file name without its extension as the table
' name.
tblName = Left(ImportFile, (InStr(1, ImportFile, ".") - 1))
' Change dBase III on the next line to the type of file you
' want to import.
DoCmd.TransferText acImportDelim, "MySpecs", tblName, ImportFile, Yes
ImportFile = Dir
Loop
End Sub

The problem is that unless every table is exactly the same you get an error, because the spec: "MySpec" needs to exactly define the table you want to import.

Am I missing something simple? Is there an easy way to do this?

I would think that becasue the defaults when importing a text file work, why can't you just import using the TransferText method and use the defaults....

Please help, this is really frustrating.

Cheers
Sep 19 '07 #1
1 2236
MMcCarthy
14,534 Expert Mod 8TB
There isn't an "easy" way to do this but you can do it using code. Have a look at this tutorial.

Import csv (comma separated value) file
Sep 30 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: rbt | last post by:
Here's the scenario: You have many hundred gigabytes of data... possible even a terabyte or two. Within this data, you have private, sensitive information (US social security numbers) about your...
0
by: Thomas Bartkus | last post by:
Can anyone show an example MySQL command to import a text file into a table? I have a massive qty of data to get into a MySQL database on a server over the internet. Shouldn't I be able to do...
2
by: steve | last post by:
Hi, I have researched but have not found a good solution to this problem. I am importing large amounts of data (over 50 Meg) into a new mysql db that I set up. I use >mysql dbname <...
1
by: Emilio | last post by:
(MS Access 2002) Hello, I'm working with some big Census (PUMS) files, and I run into a peculiar problem once the data field exceeds five integers. I'll explain every step, since I am doing it in...
17
by: OdAwG | last post by:
Just some questions regarding tables. I am new Access Database and need a little help. I have the following data listed below 01. I have a table called tbl_Customer with the following...
5
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All...
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
0
by: fboweb.com | last post by:
Hey there! I have a DTS import package from an old SQL server that takes flat text files, does some munging on the columns using ActiveX scripts and imports those flat files to various tables. ...
1
by: Kosmos | last post by:
Hey guys, I'm fairly familiar with access by now, but I've never worked with importing text into an access database. I have some fairly large text files (lets say, for example, a folder of 20 text...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.