I am really tired and should know this.... but I need help getting an ID field on a text that is right justified to grab the up to 4 number id from right to left. PLEASE HELP!!! I'm stuck until i figure this out.
Here's my function
Option Compare Database
Option Explicit
Public Function TU1()
Dim dbsTime As Database
Dim rsttable As recordset
Dim f As String
Dim a As Integer, b As Integer
Dim datastring As String
f = InputBox("What is the TXT file", "Text file", ""
f = "L:\HFC Trouble Ticket Database\" & f & ".TXT"
Open f For Input As #1
Set dbsTime = CurrentDb()
Set rsttable = CurrentDb().OpenRecordset("TmeUtl"
Dim mu As Integer, ID As String, min As Integer
Dim datee As String, fn As String
datee = ""
mu = 0
ID = 0
min = 0
fn = ""
b = 0
Do While Not EOF(1)
a = 0
Line Input #1, datastring
If Mid(datastring, 4, 1) = "MU: " Then mu = LTrim(RTrim(Mid(datastring, 5, 3)))
If Mid(datastring, 37, 6) = "Date: " Then datee = Mid(datastring, 43, 8)
If Mid(datastring, 9, 1) = "0" Then a = 1
If Mid(datastring, 9, 1) = "1" Then a = 1
If Mid(datastring, 9, 1) = "2" Then a = 1
If Mid(datastring, 9, 1) = "3" Then a = 1
If Mid(datastring, 9, 1) = "4" Then a = 1
If Mid(datastring, 9, 1) = "5" Then a = 1
If Mid(datastring, 9, 1) = "6" Then a = 1
If Mid(datastring, 9, 1) = "7" Then a = 1
If Mid(datastring, 9, 1) = "8" Then a = 1
If Mid(datastring, 9, 1) = "9" Then a = 1
If a = 1 Then
b = 0
ID = mid(datastring, 1,5)
a = 0
End If
If Mid(datastring, 1, 7) = "Summary" Then b = 1
If Mid(datastring, 70, 1) = "." And Mid(datastring, 73, 1) = "%" And b = 0 Then
fn = Trim(Mid(datastring, 33, 22))
min = 60 * Trim(Mid(datastring, 59, 3)) + Trim(Mid(datastring, 63, 2))
If b = 0 Then AddInTU rsttable, datee, mu, ID, fn, min
End If
Loop
Close #1
End Function
Public Function AddInTU(rsta, datea, mua, IDa, fna, mina)
With rsta
.AddNew
!IEXid = IDa
!Date = datea
!Function = fna
!minutes = mina
!Time = Now()
!mu = mua
.Update
.Bookmark = .LastModified
End With
End Function
Here's my function
Option Compare Database
Option Explicit
Public Function TU1()
Dim dbsTime As Database
Dim rsttable As recordset
Dim f As String
Dim a As Integer, b As Integer
Dim datastring As String
f = InputBox("What is the TXT file", "Text file", ""
f = "L:\HFC Trouble Ticket Database\" & f & ".TXT"
Open f For Input As #1
Set dbsTime = CurrentDb()
Set rsttable = CurrentDb().OpenRecordset("TmeUtl"
Dim mu As Integer, ID As String, min As Integer
Dim datee As String, fn As String
datee = ""
mu = 0
ID = 0
min = 0
fn = ""
b = 0
Do While Not EOF(1)
a = 0
Line Input #1, datastring
If Mid(datastring, 4, 1) = "MU: " Then mu = LTrim(RTrim(Mid(datastring, 5, 3)))
If Mid(datastring, 37, 6) = "Date: " Then datee = Mid(datastring, 43, 8)
If Mid(datastring, 9, 1) = "0" Then a = 1
If Mid(datastring, 9, 1) = "1" Then a = 1
If Mid(datastring, 9, 1) = "2" Then a = 1
If Mid(datastring, 9, 1) = "3" Then a = 1
If Mid(datastring, 9, 1) = "4" Then a = 1
If Mid(datastring, 9, 1) = "5" Then a = 1
If Mid(datastring, 9, 1) = "6" Then a = 1
If Mid(datastring, 9, 1) = "7" Then a = 1
If Mid(datastring, 9, 1) = "8" Then a = 1
If Mid(datastring, 9, 1) = "9" Then a = 1
If a = 1 Then
b = 0
ID = mid(datastring, 1,5)
a = 0
End If
If Mid(datastring, 1, 7) = "Summary" Then b = 1
If Mid(datastring, 70, 1) = "." And Mid(datastring, 73, 1) = "%" And b = 0 Then
fn = Trim(Mid(datastring, 33, 22))
min = 60 * Trim(Mid(datastring, 59, 3)) + Trim(Mid(datastring, 63, 2))
If b = 0 Then AddInTU rsttable, datee, mu, ID, fn, min
End If
Loop
Close #1
End Function
Public Function AddInTU(rsta, datea, mua, IDa, fna, mina)
With rsta
.AddNew
!IEXid = IDa
!Date = datea
!Function = fna
!minutes = mina
!Time = Now()
!mu = mua
.Update
.Bookmark = .LastModified
End With
End Function