A
AccessVBBef
Hello,
I currently have this code to input into one record per file
Public Function InputValues()
Dim intInputFile As Integer
Dim strLineIn As String
Dim strFileToImport As String
Dim intCounter As Integer
Dim strText As String
Dim intFindDelim As Integer
strFileToImport = "C:\InputFile.txt"
intInputFile = FreeFile
Open strFileToImport For Input As intInputFile
'--open the file for reading, skipping the first four lines
For intCounter = 1 To 4
Line Input #intInputFile, strLineIn
Next intCounter
Set rst = CurrentDb.OpenRecordset("tblRecords")
rst.AddNew
intCounter = 0
'--read the rest of the file. Basic idea is that intFieldNo
(zero-based) = the sort of offset of the value
'--IOW, if you loop through a counter, the counter= 0 at 5 (line
1). then these will match the field offsets
'--in the table.
Do Until EOF(intInputFile)
Line Input #intInputFile, strLineIn
'strLineIn needs to be parsed a little - strip off the junk
intFindDelim = InStr(1, strLineIn, "=", vbTextCompare)
If intFindDelim = 0 Then Exit Do
'--trim off the junk
strText = Trim$(Right$(strLineIn, Len(strLineIn) -
intFindDelim))
'--write the field to the record
rst.Fields(intCounter) = strText
intCounter = intCounter + 1
Loop
rst.Update
rst.Close
Close intInputFile
Set rst = Nothing
MsgBox "All Done!"
'DoCmd.OpenTable "Application"
End Function
I need to be able to loop this every 25 lines per record - skipping the
input of the 1st 5 lines and the last line.
I currently have this code to input into one record per file
Public Function InputValues()
Dim intInputFile As Integer
Dim strLineIn As String
Dim strFileToImport As String
Dim intCounter As Integer
Dim strText As String
Dim intFindDelim As Integer
strFileToImport = "C:\InputFile.txt"
intInputFile = FreeFile
Open strFileToImport For Input As intInputFile
'--open the file for reading, skipping the first four lines
For intCounter = 1 To 4
Line Input #intInputFile, strLineIn
Next intCounter
Set rst = CurrentDb.OpenRecordset("tblRecords")
rst.AddNew
intCounter = 0
'--read the rest of the file. Basic idea is that intFieldNo
(zero-based) = the sort of offset of the value
'--IOW, if you loop through a counter, the counter= 0 at 5 (line
1). then these will match the field offsets
'--in the table.
Do Until EOF(intInputFile)
Line Input #intInputFile, strLineIn
'strLineIn needs to be parsed a little - strip off the junk
intFindDelim = InStr(1, strLineIn, "=", vbTextCompare)
If intFindDelim = 0 Then Exit Do
'--trim off the junk
strText = Trim$(Right$(strLineIn, Len(strLineIn) -
intFindDelim))
'--write the field to the record
rst.Fields(intCounter) = strText
intCounter = intCounter + 1
Loop
rst.Update
rst.Close
Close intInputFile
Set rst = Nothing
MsgBox "All Done!"
'DoCmd.OpenTable "Application"
End Function
I need to be able to loop this every 25 lines per record - skipping the
input of the 1st 5 lines and the last line.