Solved

Importing text to Access via VB ADO data control

Posted on 2000-04-03
1
147 Views
Last Modified: 2010-05-02
I have an ASCII Text file, 7 fields.  I need to import to an MS Access table.  This  will happen weekly, the old data must be deleted in the Access table.  I wish to do this using Visual Basic 6.0 and the ADO data control.  Can anyone help out with the code.

I am just learning Visual Basic, so I need some help.

Thanks in Advance.
0
Comment
Question by:brabo
[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
1 Comment
 
LVL 1

Accepted Solution

by:
ariell earned 50 total points
ID: 4372602
1. add a reference to MSACC8.OLB
2. strFileName will specify the path\file etc. to import
3. if it doesn't work i have somthing more efficient. mail me ariell@clal-ins.co.il

Public Sub CreateAccessFile()
 
  Dim objAccess As New Access.Application
 
  If Len(Dir(strFileName)) Then Kill (strFileName)
  objAccess.Visible = False
  objAccess.NewCurrentDatabase strFileName
  objAccess.DoCmd.TransferText , , "Table1", FileName, True
 
  Set objAccess = Nothing
 
  Kill (strTempFileName)
 
End Sub
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 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