Code
Below is the code. I am converting a text file into an Access table. The text file is 467 pages. However I am receiving about 1/3 of the records. It skips the first record reads the second record then it skips 3rd record onward until it gets to the next page. Only then it reads the second record again. There are three lines for each record. Very confusing. Hope this helps.
Set dbvar = CurrentDb
Set rsimport = dbvar.OpenRecordset("PH010502", dbOpenDynaset)
Open "Y:/ops_programming/applications/first point/ph0105.txt " For Input As #1
DoCmd.SetWarnings False
DoCmd.OpenQuery "PHDel", acViewNormal, acEdit
DoCmd.SetWarnings True
Do While Not EOF(1)
Do Until strtextline = " BALANCE SVC DATE ADDR PHONE NUMBER PT PAY DATE C T"
Line Input #1, strtextline
If EOF(1) Then
GoTo Endroutine
End If
Loop
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline
Line Input #1, strtextline2
Line Input #1, Strtextline3
stramtplaced = Left(strtextline, 17)
strlstsrv = Mid(strtextline, 18, 10)
strps = InStr(31, Strtextline3, ",")
strfirst = Trim(Mid(Strtextline3, strps + 1, 10))
strlast = Trim(Left(Strtextline3, strps))
strmailing = Mid(strtextline, 54, 29)
strhome = Mid(strtextline, 83, 15)
strssn = Mid(strtextline2, 27, 27)
strcity = Mid(strtextline2, 54, 23)
strstate = Mid(strtextline2, 78, 2)
strzip = Mid(Strtextline3, 54, 6)
stracct = Mid(strtextline, 98, 12)
strlstpmt = Mid(strtextline, 110, 13)
With rsimport
.AddNew
![Amt Placed for Collection] = stramtplaced
![Date of Last Service] = strlstsrv
![First Name] = strfirst
![last name] = strlast
![last name] = Replace(![last name], ",", "")
![Mailing Address] = strmailing
![Home Phone Number] = strhome
![SSN] = strssn
![City] = strcity
![State] = strstate
![Zip] = strzip
![Acct or Ref Number] = stracct
![Date of Last Payment] = strlstpmt
.Update
.MoveNext
End With
Line Input #1, strtextline
Loop
Endroutine:
Close #1
MsgBox "Process Complete."