Public Sub ImportIW(strFile As String)
' ***************************************************
' * Open a Text File And Loop Through It *
' ***************************************************
Dim intFile As Integer
Dim StrIn As String
Dim TheSOL_ID As String
Dim TheUser_ID As String
Dim TheLoanAcctNo As String
Dim TheDebitAcctNo As String
Dim TheAcceptedDate As String
Dim TheAmount As String
Dim TheStartChqNo As String
Dim TheBankName As String
Dim ThePresentationDate As String
Dim TheChqLodgedNo As String
Dim TheSetNo As String
Dim TempArray() As String
Dim StartRead As Boolean
intFile = FreeFile()
Open strFile For Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, StrIn
If InStr(StrIn, "SOL ID :") > 0 Then
'Debug.Print strIn
TheSOL_ID = FindAfter(StrIn, "SOL ID :")
' Debug.Print TheSOL_ID
ElseIf InStr(StrIn, "USER ID :") > 0 Then
TheUser_ID = FindAfter(StrIn, "USER ID :")
StartRead = True
' Debug.Print TheUser_ID
ElseIf StrIn = "" Then
StartRead = False
ElseIf StartRead Then
TempArray = GetCleanArray(StrIn)
TheLoanAcctNo = TempArray(0)
TheDebitAcctNo = TempArray(1)
TheAcceptedDate = TempArray(2)
TheAmount = TempArray(3)
TheStartChqNo = TempArray(4)
TheBankName = TempArray(5)
ThePresentationDate = TempArray(6)
TheChqLodgedNo = TempArray(7)
TheSetNo = TempArray(8)
' Debug.Print TheLoanAcctNo
' Debug.Print TheDebitAcctNo
' Debug.Print TheAcceptedDate
' Debug.Print TheAmount
' Debug.Print TheStartChqNo
' Debug.Print TheBankName
' Debug.Print ThePresentationDate
' Debug.Print TheChqLodgedNo
' Debug.Print TheSetNo
InsertIW TheSOL_ID, TheUser_ID, TheLoanAcctNo, TheDebitAcctNo, TheAcceptedDate, TheAmount, TheStartChqNo, TheBankName, ThePresentationDate, TheChqLodgedNo, TheSetNo
End If
Loop
Close #intFile
End Sub
Public Sub InsertIW(TheSOL_ID As String, TheUser_ID As String, TheLoanAcctNo As String, TheDebitAcctNo As String, TheAcceptedDate As String, TheAmount As String, TheStartChqNo As String, TheBankName As String, ThePresentationDate As String, TheChqLodgedNo As String, TheSetNo As String)
'Put your real table name below
On Error GoTo errlbl
Const TableName = "tblIW"
Dim strSql As String
Dim rs As DAO.Recordset
'Insert was just too long, figured easier to do with recordset
'strSql = "Insert Into " & TableName & "(Sol_ID, User_ID, Loan_Acct_Number, Debit_Acct_Number, Page, MOM_ID, MOM_TXT, MOM_MMC, Department_Name) VALUES ( " & TheSegment & ", " & ThePrintDate & ", " & ThePage & ", " & TheMOM & ", " & TheMOM_Txt & ", " & TheMOM_MMC & ", " & TheDepartment & ")"
'Debug.Print strSql
'CurrentDb.Execute strSql
Set rs = CurrentDb.OpenRecordset("tblIW", dbOpenDynaset)
rs.AddNew
rs!SOl_ID = TheSOL_ID
rs!User_ID = TheUser_ID
rs!Loan_Acct_Number = TheLoanAcctNo
rs!Debit_Acct_Number = TheDebitAcctNo
rs!Accepted_Date = CDate(TheAcceptedDate)
rs!Amount = CCur(TheAmount)
rs!Start_Check_Number = CLng(TheStartChqNo)
rs!Bank_Name = TheBankName
rs!Presentation_Date = CDate(ThePresentationDate)
rs!Number_Lodged = CLng(TheChqLodgedNo)
rs!set_Number = TheSetNo
rs.Update
Exit Sub
errlbl:
Debug.Print Err.Number & " " & Err.Description & " " & vbCrLf & strSql
Resume Next
End Sub