Solved

Import Text file into MS Access 2007

Posted on 2014-11-27
5
192 Views
Last Modified: 2014-11-30
I have a text file (.txt) which has thousands of lines with the following format:

aaaaaaa-bbbb;CCCCCCCC;DDDD

each position represents customer_number;customer_name;project_name in the database respectively.  Please note there is no field heading in the text file

MS Access 2007 database has a table name "customer" which has the fields as follows:

customer_number,customer_name,project_name respectively.


I should be grateful if someone could help me providing a VB script or a batch file to run an import of the data in the text file into MS Access 2007.  Thank you.
0
Comment
Question by:yimsoin57
[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
  • 2
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40470038
Just run the import wizard at menu External Data. Choose to link the data, not import.
In this, select the separator as semicolon.

Then create a simple append query that uses the linked data as source and your Customer table as target.

/gustav
0
 

Author Comment

by:yimsoin57
ID: 40470061
Actually my text file gets updated twice a day which I do not know which lines are updated.  I need the data be imported into the data and replace the old data not append.
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40470063
Well, then you would use an update query rather than an append query.

/gustav
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40470640
Some of it can be coded.
As /gustav  suggests, create a linked table.
I do this with CSV files all the time.

Then for code
'kill everything in Customer
DoCmd.SetWarnings False
CurrentDb.Execute "DELETE Customer.* FROM Customer;", dbSeeChanges
DoCmd.SetWarnings True
'Insert everything from the linked CSV into Customer
'code for the insert here

Open in new window


Now, if you have created the linked table as /gustav has suggested, tell us the name of the new linked table and perhaps /gustav would be so kind as to supply the insert part of the SQL code (I always use recordset code, which wouldn't be efficient for a bulk insert like this)
0
 

Author Closing Comment

by:yimsoin57
ID: 40473170
Everything is perfectly done as advised.  Thank you.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
INSERT value into first row in 75 workbooks 8 37
Moving away from Access 2003 adp files 4 48
Cant delete records in query 8 49
Using a combo box to search a form. 3 36
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

734 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