473,473 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Import Text Code does not see my file??

31 New Member
Can someone tell my why this is not seeing my file in its location because it is there. Iam trying to import all .txt files in one folder and then archive in a seperate folder. I am not an expert by any means.. know enough to be dangerous..

Expand|Select|Wrap|Line Numbers
  1. Private Sub ImportFiles_Click()
  2.     Dim RSO As Object
  3.     Dim strFolderPath As String
  4.     Dim strFile As String
  5.     Set RSO = CreateObject("Scripting.FileSystemObject")
  6.  
  7.     strFolderPath = "C:\SFOEDL\TL"
  8.  
  9.    strFile = Dir(strFolderPath & "\*.txt", vbNormal)
  10.     Do While strFile <> ""
  11.         If strFile > " " Then
  12.  
  13.         DoCmd.TransferText acImportFixed, "TLimport", "TblTL", strFile, False
  14.         Name strFolderPath & strFile As "C:\SFOEDL\TL\Archive"
  15.         End If
  16.  
  17.         strFile = Dir()
  18.      Loop
  19.  
  20. End Sub
Nov 16 '10 #1
2 1685
ADezii
8,834 Recognized Expert Expert
You do not need the Reference to the Microsoft Scripting Runtime Object Library. The basic, and simplest, syntax for referencing all Text Files in a given Folder would be:
Expand|Select|Wrap|Line Numbers
  1. Dim strFolderPath As String
  2. Dim strFile As String
  3.  
  4. strFolderPath = "C:\SFOEDL\TL"
  5.  
  6. strFile = Dir(strFolderPath & "\*.txt", vbNormal)
  7.  
  8. Do While strFile <> ""
  9.   Debug.Print strFile
  10.     strFile = Dir()
  11. Loop
Nov 16 '10 #2
Wayne L
31 New Member
Found out what was missing..
DoCmd.TransferText acImportFixed, "TLimport", "TblTL", strFolderPath & strFile,
I needed to add the folder path and the file together..
Attached code is what worked. Thanks for the assist!!!

Expand|Select|Wrap|Line Numbers
  1. Dim strFolderPath As String
  2. Dim strFile As String
  3.  
  4. strFolderPath = "C:\SFOEDL\TL\"
  5.  
  6. strFile = Dir(strFolderPath & "\*.txt", vbNormal)
  7.  
  8. Do While strFile <> ""
  9. If strFile <> "." And strFile <> ".." Then
  10.   Debug.Print strFile
  11.     strFile = Dir()
  12.     DoCmd.TransferText acImportFixed, "TLimport", "TblTL", strFolderPath & strFile, False
  13.     End If
  14. Loop
Nov 16 '10 #3

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

Similar topics

2
by: Wolfgang.Stoecher | last post by:
Hi, another beginner's question: when I import a module, change the corresponding textfile and try to import the same module again, it looks like the internal code does not change (the...
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
5
by: David Aylott | last post by:
Greetings When I use the import text wizard with a fixed width text file, I add a break at the correct column but it doesn't line up with the text. It seems that the display is shown in a...
2
by: John | last post by:
HI, I'm having trouble importing text files. I had problem with Access '97 that forced me to reinstall. After I did this I couldn't import text files. The Help file recommends reinstall again,...
3
by: holdemfoldem | last post by:
Hi. I'm new to this board and have a few questions about using the method referred to in the topic of this message. I have manually transferred over 1/2 million records from a text file into my...
2
by: bienwell | last post by:
Hi all, Do you have any source code to import data from Excel file or text file into database in ASP.NET program ? Please give me your reference if you have. Thanks in advance
0
by: Bob | last post by:
Hi all, I'm trying to use code to start the text/spreadsheet import wizard because my file will change all the time and so I can't define a spec for it - I want the user to define everything. ...
2
by: KingoftheKings | last post by:
I'm new here. I want a help with VB codes that will import text or excel files from a specified directory in to an existing or new Access table. I have written some codes, but when I click the...
3
by: sena0112 | last post by:
Hi, I'm a beginner in visual basic and programming. My programme needs to let the user browse for a text file and when the user press a command button, the programme will list out the text file into...
9
by: a | last post by:
Dear friends I want import data from CSV file to mdb file How can I do that in vb.net?
0
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...
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...
1
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.