i have tried to do this on my computer which is running access 2003 and the option to "save as" is greyed out. I presumed it was because i was using an ADP database instead of an MDB however i may be wrong.
Main Topics
Browse All TopicsI have a file that gets delivered to us every day in a text file that looks like this.
75734||Danny|123123|R|2, 34, 12|27/10/2007 15:16:42|errorsoccured
I need to import this file into an sql table using VBA on a access front end button. It is pipe deliminated.
how could i do this.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry- I'm wrong.
I couldn't think of any reason why this should not work. But apparently it doesn't.
See:
http://support.microsoft.c
i thought it was weird disabling it also.
Is there any way i could do the import using VBA code?
I thought i could i could import it into a table and then read the characters until i reached a | save them as a string and then input that string into a column of a table using an insert command? however im not sure how i would script the reading of the row until i reached a | then carried on in the next 1 etc or if it is even possible.
You can use a schema.ini file instead.
I've never done this but here are some instructions on how to create one..
http://support.microsoft.c
Another version of how-to:
http://www.ehow.com/how_52
i read through the 2nd one you posted and it says
Design a new table with only one field having a data type of text.
The field is named using the convention of Col1,Col2,Col3,and so on.
The field width property is what you use to define how to break up each line of the imported text file. For example field Col1 with a width property of 25 would hold the first 25 characters, Col2 with a width of 10 would hold next ten characters. So set each field width based on how you want to divide each line or row of the text file.
looking at the layout it would have to be a fixed width?? However the length of the columns can change on my import they are not all a fixed width.
I have found a way to do it using the split() function
However i have typed the Value in my self.
Is it possible to read the value from a table called tblimport with 1 column called input.
and it would go through the table till it has split off all the entries. so instead of me putting in
Split("504122474|1363454|D
I would have
dim sqlimport as string
sqlimport = "select tblimport.import from tblimport"
which would then pick up 3 entries like so
504122474|1363454|Dan James|02408829|29/10/2009 20:00:37
123|1363455|Mark Johnson|02408830|29/10/200
14587045|1363456|David Jones|02408831|29/10/2009 20:01:26
So it would then split it and would appear in table tbltest like so
Field 1 Field 2 Field 3 Field 4 Field 5
504122474 1363454 Dan James 2408829 29/10/2009 20:00
504122482 1363455 Mark Johnson 2408830 29/10/2009 20:01
166287045 1363456 David Jones 2408831 29/10/2009 20:01
I believe i would have to do a do while not EOF or something similar however i am unsure how i would code that on top of the pre-existing code?
If anyone is ever interested in this in the future this is the final code i have to split the pipe deliminated text file.
__________________________
Dim TextLine
Dim avarSplit As Variant
Dim intIndex As Integer
CurrentProject.Connection.
"delete from tbltest"
Open "C:\test.txt" For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
Debug.Print TextLine ' Print . Textline would be your data value for use in your own 'split' code.
avarSplit = Split(TextLine, "|")
For intIndex = LBound(avarSplit) To UBound(avarSplit)
'MsgBox "Item " & intIndex & " is " & avarSplit(intIndex) & _
' " which is " & Len(avarSplit(intIndex)) & " characters long", vbInformation
Next
CurrentProject.Connection.
"insert into tbltest ([Column1], [Column2], [Column3], [Column4], [Column5]) select '" & avarSplit(0) & "', '" & avarSplit(1) & "', '" & avarSplit(2) & "', '" & avarSplit(3) & "','" & avarSplit(4) & "'"
Loop
Close #1 ' Close file
__________________________
Business Accounts
Answer for Membership
by: peter57rPosted on 2009-10-29 at 02:42:05ID: 25691855
Go through the process manually and create an import spec.
Then use the spec in a docmd.transfertext command.