How to Import Text File into Microsoft Access Table Using DDEID: Q113905
|
This article shows you how to implement the built-in TransferText command
of Microsoft Access to import data from a text file into a Microsoft Access
Table using DDE. This method is faster than the alternate method outlined
in the following article in the Microsoft Knowledge Base:
Q103807 : How to Convert a Text File into a New Access Database
The TransferText command is used in Access Basic to import data from a text
file into a table. If the table specified doesn't exist, the TransferText
command creates the table. If the table does exist, the text file's format
must match that of the existing table.
The text file can be comma delimited with strings enclosed in quotation
marks or it can be of fixed width. The delimiter and fixed width settings
can be set up in Microsoft Access by choosing Imp/Exp Setup from the File
menu. For more information on these settings, please consult the Microsoft
Access Help menu.
Sub Command1_Click ()
Dim cmd As String ' Holds DDEExecute command.
On Error GoTo DDEerr ' Error trap.
' Make sure there isn't an existing DDE conversation:
text1.LinkMode = 0
' Set up the DDE link:
text1.LinkTopic = "MSACCESS|C:\ACCESS\NWIND.MDB"
text1.LinkItem = "All"
text1.LinkMode = 2
' DDEExecute command to import text file into Microsoft Access Table:
cmd = "[TransferText ,,'Shippers','C:\ACCESS\SHIPPERS.TXT']"
' Execute the TransferText command and close the DDE link:
text1.LinkExecute cmd
text1.LinkMode = 0
MsgBox "Transfer OK"
Exit Sub
DDEerr:
' An error has occurred.
MsgBox Error
MsgBox "Error in transfer."
Exit Sub
End Sub
Q96845 : How to Use DDE to Display Microsoft Access Data in VB
Additional query words: 3.00 4.00 vb416
Keywords : kbcode IAPDDE
Version : 3.00 4.00
Platform : WINDOWS
Issue type :
Last Reviewed: June 14, 1999