Hi All,
I'm attempting to automate the import of .txt files into Access.
When I use the File > Get External Data > Import function and select my import specification, the data is imported correctly and in order.
When I use the TransferText macro, and specify all the same paramenters i.e. fixed width, import specification, file path, table name etc, the data is imported; however, it is 'jumbled.' It is not in the same order as the text file (does not import the same way as when I do it manually).
It is critical that the data is imported in the correct order for it to be useful.
Has anyone ever encountered this issue before? Can someone provide some insights?
Many thanks!!!
5 3480 MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi All,
I'm attempting to automate the import of .txt files into Access.
When I use the File > Get External Data > Import function and select my import specification, the data is imported correctly and in order.
When I use the TransferText macro, and specify all the same paramenters i.e. fixed width, import specification, file path, table name etc, the data is imported; however, it is 'jumbled.' It is not in the same order as the text file (does not import the same way as when I do it manually).
It is critical that the data is imported in the correct order for it to be useful.
Has anyone ever encountered this issue before? Can someone provide some insights?
Many thanks!!!
Check your specification file. There may be some problems with it.
Check your specification file. There may be some problems with it.
I use the same specification file in TransferText as I do using Menu > import...
MMcCarthy 14,534
Recognized Expert Moderator MVP
I use the same specification file in TransferText as I do using Menu > import...
Check it anyway.
Check it anyway.
I've been banging my head against the wall for the past 24 hrs because of this problem. This was seemingly a straightforward task. I've checked and double checked the import specification. As I mentioned before, I use the same one when I import manually as I do for the TransferText macro. Still not sure why the automation method doesn't work properly...
MMcCarthy 14,534
Recognized Expert Moderator MVP
Honestly not sure what is going on here. I've never had this problem. Usually though I use VBA to import text files. You can use code something like the following. It gives better control anyway. -
Function ImportTextFile()
-
Dim fhandle1 As Integer
-
Dim fline As String
-
Dim fPath As String
-
Dim fld1 As Long
-
Dim fld2 As Date
-
Dim fld3 As String
-
Dim strSQL As String
-
-
fpath = "Full path of file.txt"
-
' open the text file to be read
-
fhandle1 = FreeFile()
-
Open fpath For Input Access Read Lock Write As #fhandle1
-
-
Do While Not EOF(fhandle1) ' loop until you reach the end of the file.
-
-
Line Input #fhandle1, fline
-
-
fld1 = Left(fline, 5)
-
fld2 = Mid(fline, 6, 10)
-
fld3 = Left(fline, 16, 30)
-
-
strSQL = "INSERT INTO TableName (Field1, Field2, Field3) " & _
-
"VALUES(" & fld1 & ", #" & fld2 "#, '" & fld3 & "')"
-
DoCmd.RunSQL strSQL
-
Loop
-
-
Close #fhandle1
-
-
End Function
-
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Grim Reaper |
last post by:
I am importing a .csv file into Access that has 37 fields. My problem is
that sometimes the last field only has data at the end of the column (it
looks like when you import a file into Access, for...
|
by: D Mat |
last post by:
Hi,
I'm trying to get MS Access 2000 to automatically import a series of
(~200) flat text, tab delimited, data files into a single Access table,
with consistent fields and rows.
The files have...
|
by: Roald Oines |
last post by:
Hi,
I'm working on converting several of my Access 97 databases to Access
2002 format (the company's changing from NT 4 to XP and updating Office
at the same time), and this one has me stumped....
|
by: matchine |
last post by:
This is a recommendation based on my research on an issue with the
transfer text functionality. The comments below were from a tech I
approched for help.
"The transfer text process blocked...
|
by: hedgracer |
last post by:
I have a strange problem with a docmd.transfertext statement. I have
set up an import specification to transfer in a .txt file by fixed
width. When I do the import using the specification the file...
| |
by: john |
last post by:
I have 400 different Excel-spreadsheetfiles, same structure, all with only
one record in it, and all residing in the same folder. Every now and then
new Excel files are being added. In my Access...
|
by: Alice |
last post by:
I'm trying to upload all .txt files from a specific folder using the
following code, but it didn't work. HELP
The problem lies in DoCmd.TransferText acImportFixed, "Imperial Import...
|
by: derfer |
last post by:
I am trying to import a .inf file into access (the file comes from the output of some 3rd party software). I have managed to convert the file by opeing it in notepad and re-saving then a seperate...
|
by: Irene |
last post by:
Hi,
I have an MS Access Database with 1 Table containing about 2 million records
in Unicode (diferent languages).
I would like to export the Table to a Text file (CSV, Tab, etc.)
Access...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |