473,799 Members | 2,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Importing Text File

I have a problem of importing a text file into Access. The text file
will be imported using a delimiter, say ( , ) for example. This should
be imported into the database. An example is:

John, is, a, boy
Ada, is, a, girl

I have tried using the DoCmd.TransferT ext but I am not getting results.

Nov 13 '05 #1
10 2982
hendafe wrote:
I have a problem of importing a text file into Access. The text file
will be imported using a delimiter, say ( , ) for example. This should
be imported into the database. An example is:

John, is, a, boy
Ada, is, a, girl

I have tried using the DoCmd.TransferT ext but I am not getting results.

If you use the Access File - Get External Data - Import command, you can
specify what delimiter, if any is to be used. Look closely when you do
this.

Bob
Nov 13 '05 #2
"hendafe" <he*****@yahoo. com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I have a problem of importing a text file into Access. The text file
will be imported using a delimiter, say ( , ) for example.
Just to be pedantic, ( , ) is a "separator" not a delimiter.
A delimiter, if used, is usually double-quotes surrounding text.
Delimiters are needed around text fields so that commas can be included in
the text. eg
.... , "24 John Street, Bay Village", ...
This should be imported into the database.


What did that mean? Do you want the commas to be imported into the database
too?
If so, TransferText may not be the way to go.
Nov 13 '05 #3
I have tried using the Get External Data - Import command in the File
menu, and it is working perfectly well.
The problem, these text files are frequently added into a particular
folder, more than one.
I want to be able to loop through this folder and import the whole of
them into a table.
This should be done through a form, by clicking a command button.
Any help with that

Nov 13 '05 #4
Ian Hinson wrote:
"hendafe" <he*****@yahoo. com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I have a problem of importing a text file into Access. The text file
will be imported using a delimiter, say ( , ) for example.

Just to be pedantic, ( , ) is a "separator" not a delimiter.
A delimiter, if used, is usually double-quotes surrounding text.
Delimiters are needed around text fields so that commas can be included in
the text. eg
... , "24 John Street, Bay Village", ...

This should be imported into the database.

What did that mean? Do you want the commas to be imported into the database
too?
If so, TransferText may not be the way to go.

Pedantic or not, the Access Import Text Wizard states:
"Delimited - Characters such as comma or tab separate each field".

Consider this definition I found through google,
de·lim·it·er (d-lm-tr)
n. Computer Science
A character or sequence of characters marking the beginning or end of a
unit of data.

Bob
Nov 13 '05 #5
Thanks.
The commas are not going to be imported into the database.
I am supposed to use a command button in a form to import
these files. The command button is supposed to collect these
different text files in the folder and transfer these text into a table
in the Database.
Any idea.

Nov 13 '05 #6
I have tried using the Get External Data - Import command in the File
menu, and it is working perfectly well.
The problem, these text files are frequently added into a particular
folder, more than one.
I want to be able to loop through this folder and import the whole of
them into a table.
This should be done through a form, by clicking a command button.
Any help with that

Nov 13 '05 #7
I have tried using the Get External Data - Import command in the File
menu, and it is working perfectly well.
The problem, these text files are frequently added into a particular
folder, more than one.
I want to be able to loop through this folder and import the whole of
them into a table.
This should be done through a form, by clicking a command button.
Any help with that

Nov 13 '05 #8

hendafe wrote:
Thanks.
The commas are not going to be imported into the database.
I am supposed to use a command button in a form to import
these files. The command button is supposed to collect these
different text files in the folder and transfer these text into a table
in the Database.
Any ideas.

Yes, when you imported via MS-Access's build import function, Access
save a spec. Run the process again and click on advance which should
be through the left on any of the forms. Your DoCmd.transfer will need
to use than spec as well.

As for as running a routine to process multiple files via one button,
you'll need use VBA.
Here is a sample project I did for a client:
Function IndexPC()
Set fs = Application.Fil eSearch
LoadCount = 0
PathStr(0) = DLookup("[Input Dir]", "ImportSettings ", "[ID]
=0")
PathStr(1) = DLookup("[Archive Dir]", "ImportSettings ", "[ID]
=0")
PathStr(3) = DLookup("[Archive File]", "ImportSettings ", "[ID]
=0")
PathStr(4) = DLookup("[Purge File]", "ImportSettings ", "[ID]
=0")
CurrentDb.Execu te "Empty Files_New tbl"
With fs
For Counter = 1 To 1
.LookIn = PathStr(0)
.SearchSubFolde rs = False

.FileName = "*.PYX" 'Could be anything
If .Execute <> 0 Then
DoCmd.Echo True, "There were " & .FoundFiles.Cou nt & _
" file(s) found."

DoCmd.OpenForm ("LoadFiles" )
DoCmd.RepaintOb ject acForm, "LoadFiles"
For i = 1 To .FoundFiles.Cou nt
'If Forms![LoadFiles]![File Name] Is Not Null Then
DoCmd.GoToRecor d acForm, "LoadFiles" , acNewRec
Forms![LoadFiles]![File Path Name] = .FoundFiles(i)
Forms![LoadFiles]![File Name] = Dir(.FoundFiles (i))
Forms![LoadFiles]![File Size] =
FileLen(Forms![LoadFiles]![File Path Name])
Forms![LoadFiles]![File Date/Time] =
FileDateTime(Fo rms![LoadFiles]![File Path Name])
'
NeedOLE = "No"
Age = DateDiff("d", Forms![LoadFiles]![File Date/Time],
Date)
If DCount("[File Path Name]", "Files_Load ed", "[File Path
Name]='" & Forms![LoadFiles]![File Path Name] & "'") < 1 Then NeedOLE =
"YES" 'prevent reloading if already in main table
If Age > 30000 Then Call DeleteFile
If NeedOLE = "YES" Then Call LoadOLE
Next i
Else
' MsgBox "There were no files found."
End If
Next Counter
End With
DoCmd.SetWarnin gs False
DoCmd.OpenQuery "Append New Files"
CurrentDb.Execu te "Empty Files_New tbl"
DoCmd.Close acForm, "LoadFiles" , acSaveNo
If PathStr(3) = "-1" Then Call CopyAllFiles(Pa thStr(0),
PathStr(1), "*.*")

MsgBox "Loaded " & LoadCount & " Files."

End Function

Nov 13 '05 #9
Here is another sample:

Function IndexPC()
Set FS = Application.Fil eSearch
DoCmd.SetWarnin gs False
CurrentDb.Execu te "Empty New files tbl"
DoCmd.Close acForm, "LoadFiles"

With FS
For Counter = 1 To 1
DaysAge = DLookup("[Delete Days]", "FilePath", "[ID] = " &
Counter)
.LookIn = DLookup("[FilePath]", "FilePath", "[ID] = " & Counter)
'.LookIn = "%temp%"

.SearchSubFolde rs = True
.FileName = "*.*"
.Execute msoSortBySize, msoSortOrderDes cending
i = .FoundFiles.Cou nt
Beep
If i > 0 Then
DoCmd.Echo True, "There were " & .FoundFiles.Cou nt & " file(s)
found."

DoCmd.OpenForm "LoadFiles" , acDesign
DoCmd.OpenForm "LoadFiles" , acNormal

For i = 1 To .FoundFiles.Cou nt
'If Forms![LoadFiles]![File Name] Is Not Null Then
DoCmd.Echo True, .FoundFiles.Cou nt - i
DoCmd.GoToRecor d acForm, "LoadFiles" , acNewRec
Forms![LoadFiles]![File Path Name] = .FoundFiles(i)
Forms![LoadFiles]![File Name] = Dir(.FoundFiles (i))

Forms![LoadFiles]![File Size] =
FileLen(Forms![LoadFiles]![File Path Name])
Forms![LoadFiles]![File Date/Time] =
FileDateTime(Fo rms![LoadFiles]![File Path Name])
' Forms![LoadFiles]![Owner] = DLookup("[Owner]", "File
Locations", "[Order]=" & Counter)
Forms![LoadFiles]![Folder] = Left$(.FoundFil es(i),
Len(.FoundFiles (i)) - Len(Dir(.FoundF iles(i))))
Forms![LoadFiles]![Projection] =
FileDateTime(Fo rms![LoadFiles]![File Path Name]) + DaysAge
Age = DateDiff("d", Forms![LoadFiles]![File Date/Time],
Date)

If Age > DaysAge Then Call DeleteFile
'Forms![LoadFiles]![Folder] =
Forms![LoadFiles]![Folder] & " -->" &
FileLen(Forms![LoadFiles]![Folder])
' RmDir Forms![LoadFiles]![Folder]
Next i
Else
MsgBox "There were no files found."
End If
Next Counter
End With
DoCmd.OpenQuery "Append New Files"
End Function

Sub DeleteFile()
Forms![LoadFiles]![Delete] = "Yes"
Kill Forms![LoadFiles]![File Path Name]
' DoCmd.RunComman d acCmdDeleteReco rd
End Sub

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3429
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 the last field, it only checks the top few 'cells' to see if there is any data, if not, the field is not imported). How do I 'force' Access to import the field, regardless if there is data in the top of the field or not? For instance, I might...
1
3683
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am trying to avoid this extra step. can access read in this file directly into a table as append data? thank you very much for any pointers
6
2710
by: Sam Lazarus | last post by:
I need to import data from a website, but the text is arranged badly: Name:John Doe Title:Grunt ID:314159 Name:Jane Doe Title:Queen-Bee ID:271828 etc...
2
3931
by: kuhni | last post by:
Hi everybody, I am totally desperate because I cannot solve a really simple problem: I have a specific text-file which I want to import into an existing database. The problem is that the columns have different names so I receive an error message when importing via the "Get External Data"-Wizard. The second problem is that this text file includes several rows without any relevant data, only symbols like "-----" in the various columns. I...
11
2945
by: panic attack | last post by:
Hello everbody, Our system is using Sql Server 2000 on Windows XP / Windows 2000 We have a text file needs to be imported into Sql Server 2000 as a table. But we are facing a problem which is, Sql Server claims that it has a character size limit ( which is 8060 ) so it cant procceed the import operation if the text file has a record bigger then 8060. The records , in the text file, have a size bigger then 8060. So we wont be able to...
5
3183
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All districts have used the same excel template and populated the same 32 data fields (columns). I created one large excel file from all 49 files which gives me a master table of 60,000 or so records. I have tried to import this master table into access...
12
6224
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the datagrid. Once I can get to that point I need some way to be able to add new data only to the new columns that were added. Here is some of my code: //Function For Importing Data From CSV File public DataSet ConnectCSV(string filetable)
2
2736
by: Debbiedo | last post by:
I have a text file that I am importing into an Access table that was generatred from data exported from a Word file. Several (about 20-30) fields are from check boxes on the Word form. These fields have either 0 (Not checked) or 1 (Checked). Due to requirements from a third party software application, they HAVE to be either Y(Checked) or N (Not checked) and MUST be a text field in the Access table. I will be importing several thousand of...
1
2002
by: Kosmos | last post by:
Hey guys, I'm fairly familiar with access by now, but I've never worked with importing text into an access database. I have some fairly large text files (lets say, for example, a folder of 20 text files could be about 120 mb with each text file being 6 mb). I know that Access has some strict limitations on fields and their sizes and I've learned to stay away from using memos. The files are encoded health files and so they have a '~' to...
1
3243
by: aconti74 | last post by:
Hello I am new to vba programming/coding. I am writing a program that goes through a directory of text files and imports them into the database. The problem is eventually the database gets to big and needs to be compacted. I know how to compact on exit but how do you do it in a loop using vba? My old program in basic did it because it was external to access. Any ideas? 1.import text file 2.loop - check size
0
9689
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10269
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7573
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.