I have a text file that I am tryin' to import into a table.
Below is code that I am working with. I need to manipulate this code so it only adds lines that start with N123, N123 -
Any line that starts with N and then 3 numbers...
Any suggestions or examples on this would be the huckleberry. I am almost done in getting this to work the way I want!!! Below is an example of the text file, and below that is the code I'm working with.
Thanks in advance..!!!
jcw5107
Tail Schd Schd Eng Task Chgd By Added By Task
No Gtwy Date Ref Number Rev Pos ApndxApndxApndxApndx NoV? Date Date No
====================================================================================================================================
N120UP KCGN 03/24/07 EO A300-3210-22610 C E 798639N 03/12/07 15:54 02/27/07 20:28 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 724100-P1-1-L-460 S 397034N 02/27/07 20:58 02/27/07 20:58 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 725300-P2-1-L-460 S 397041N 02/27/07 21:00 02/27/07 21:00 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 792203-P4-1-L-460 S 397073N 03/12/07 15:55 02/27/07 20:30 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 801301-P1-1-L-460 S 397075N 03/12/07 15:55 02/27/07 21:01 0
------------------------------------------------------------------------------------------------------------------------------------
N124UP KCGN 03/24/07 CK PERIODIC SERVICE 12 S 396908N 03/12/07 16:58 02/27/07 21:19 0
PS12 IS EQUIVALENT TO THE P12 LISTED ON THE TALLY SHEET
Function ImportTable()
Dim dbs As Database, rst As Recordset
Dim Directory As String
Dim MyString As String
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from PlannedTasks"
DoCmd.SetWarnings True
Set dbs = CurrentDb
Directory = (Mid(dbs.Name, 1, Len(dbs.Name) - Len(Dir(dbs.Name))))
Open Directory & "\Parts Required For Scheduled Work.txt" For Input As #1
' Create a dynaset-type Recordset object based on Shoes table.
Set rst = dbs.OpenRecordset("PlannedTasks")
Do While Not EOF(1)
Line Input #1, MyString
'Add a new Record
rst.AddNew
rst!Tail = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!SchdGTWY = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!SchdDate = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!DocType = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!DocNo = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst![Date Scheduled] = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!DocRev = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!EngPos = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 4)
rst!Apndx = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!Apndx1 = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!Apndx2 = MyString
rst.Update
Loop
' Close text file.
MsgBox "Done!"
Close #1
rst.Close
Set dbs = Nothing
End Function
Below is code that I am working with. I need to manipulate this code so it only adds lines that start with N123, N123 -
Any line that starts with N and then 3 numbers...
Any suggestions or examples on this would be the huckleberry. I am almost done in getting this to work the way I want!!! Below is an example of the text file, and below that is the code I'm working with.
Thanks in advance..!!!
jcw5107
Tail Schd Schd Eng Task Chgd By Added By Task
No Gtwy Date Ref Number Rev Pos ApndxApndxApndxApndx NoV? Date Date No
====================================================================================================================================
N120UP KCGN 03/24/07 EO A300-3210-22610 C E 798639N 03/12/07 15:54 02/27/07 20:28 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 724100-P1-1-L-460 S 397034N 02/27/07 20:58 02/27/07 20:58 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 725300-P2-1-L-460 S 397041N 02/27/07 21:00 02/27/07 21:00 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 792203-P4-1-L-460 S 397073N 03/12/07 15:55 02/27/07 20:30 0
------------------------------------------------------------------------------------------------------------------------------------
N120UP KCGN 03/24/07 TC 801301-P1-1-L-460 S 397075N 03/12/07 15:55 02/27/07 21:01 0
------------------------------------------------------------------------------------------------------------------------------------
N124UP KCGN 03/24/07 CK PERIODIC SERVICE 12 S 396908N 03/12/07 16:58 02/27/07 21:19 0
PS12 IS EQUIVALENT TO THE P12 LISTED ON THE TALLY SHEET
Function ImportTable()
Dim dbs As Database, rst As Recordset
Dim Directory As String
Dim MyString As String
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from PlannedTasks"
DoCmd.SetWarnings True
Set dbs = CurrentDb
Directory = (Mid(dbs.Name, 1, Len(dbs.Name) - Len(Dir(dbs.Name))))
Open Directory & "\Parts Required For Scheduled Work.txt" For Input As #1
' Create a dynaset-type Recordset object based on Shoes table.
Set rst = dbs.OpenRecordset("PlannedTasks")
Do While Not EOF(1)
Line Input #1, MyString
'Add a new Record
rst.AddNew
rst!Tail = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!SchdGTWY = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!SchdDate = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!DocType = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!DocNo = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst![Date Scheduled] = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!DocRev = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!EngPos = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 4)
rst!Apndx = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!Apndx1 = Left(MyString, InStr(MyString, " ") - 1)
MyString = Mid(MyString, InStr(MyString, " ") + 1)
rst!Apndx2 = MyString
rst.Update
Loop
' Close text file.
MsgBox "Done!"
Close #1
rst.Close
Set dbs = Nothing
End Function