Help!
I have a text file (created in the Mainframe world) with fixed-length fields and records. I want to import to an Access table from it, using Schema.ini to identify field names and lengths. The Access table has already been defined.
I copied the following code from MSDN (Greg Stemp's article, "Much ADO About Text Files", 5 Mar 2004. I changed the value "strPathToTextFile" and the text filename in "Select * from .....". When I run the sub, it gets to the "Wscript" loop and runs 4ever, with no output.
Does anyone have any ideas on what is wrong? I'm using MS Access 2003 SP1. Here is the code:
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
strPathtoTextFile = "C:\Databases\"
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=FixedLength"""
objRecordset.Open "SELECT * FROM PhoneList.txt", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText
Do Until objRecordset.EOF
Wscript.Echo "Name: " & objRecordset.Fields.Item("FirstName")
Wscript.Echo "Department: " & objRecordset.Fields.Item("LastName")
Wscript.Echo "Extension: " & objRecordset.Fields.Item("ID")
objRecordset.MoveNext
Loop