I have a script written to import a fixed text file into an access table, but while the script will acknowledge the row count and add those rows to the database table, it does not post the fields to the table. (All rows/fields are blank.)
What am I missing in this script to copy the information that it reads to the table fields?
Private Sub Enabler_Import()
'This will be called from the Main form
Dim db As Database
Dim rstEnabler As Recordset
'Declare strings for extracting from text file
Dim sLine As String
Dim sCompany As String
Dim sCycle_date As String
Dim sPlan As String
Dim sPolicy As String
Dim sTax_qualifier As String
Dim sTrx As String
Dim sTrx_desc As String
Dim sAcct As String
Dim sMisc As String
Dim sDR As String
Dim sCR As String
Dim sState As String
Dim sMemo As String
Dim sFund As String
Dim sRev As String
Dim sCat As String
Set db = CurrentDb()
Set rstEnabler = CurrentDb.OpenRecordset("Enabler", dbOpenTable)
Open "c:\Enabler\enabler.seq" For Input As 1
Do While Not EOF(1)
Line Input #1, sLine
' Declare field variables/widths
If Len(sLine) > 200 Then
sCompany = Mid(sLine, 1, 3)
sCycle_date = Mid(sLine, 4, 8)
sPlan = Mid(sLine, 12, 10)
sPolicy = Mid(sLine, 22, 15)
sTax_qualifier = Mid(sLine, 50, 4)
sTrx = Mid(sLine, 54, 4)
sTrx_desc = Mid(sLine, 58, 30)
sAcct = Mid(sLine, 88, 25)
sMisc = Mid(sLine, 113, 40)
sDR = Mid(sLine, 153, 16)
sCR = Mid(sLine, 169, 16)
sState = Mid(sLine, 185, 2)
sMemo = Mid(sLine, 187, 2)
sFund = Mid(sLine, 240, 4)
sRev = Mid(sLine, 244, 1)
sCat = Mid(sLine, 245, 2)
rstEnabler.AddNew
End If
rstEnabler.Update
Loop
Close 1
rstEnabler.Close
MsgBox " Records have been imported", , "Enabler.seq Record Importer"
End Sub
What am I missing in this script to copy the information that it reads to the table fields?
Private Sub Enabler_Import()
'This will be called from the Main form
Dim db As Database
Dim rstEnabler As Recordset
'Declare strings for extracting from text file
Dim sLine As String
Dim sCompany As String
Dim sCycle_date As String
Dim sPlan As String
Dim sPolicy As String
Dim sTax_qualifier As String
Dim sTrx As String
Dim sTrx_desc As String
Dim sAcct As String
Dim sMisc As String
Dim sDR As String
Dim sCR As String
Dim sState As String
Dim sMemo As String
Dim sFund As String
Dim sRev As String
Dim sCat As String
Set db = CurrentDb()
Set rstEnabler = CurrentDb.OpenRecordset("Enabler", dbOpenTable)
Open "c:\Enabler\enabler.seq" For Input As 1
Do While Not EOF(1)
Line Input #1, sLine
' Declare field variables/widths
If Len(sLine) > 200 Then
sCompany = Mid(sLine, 1, 3)
sCycle_date = Mid(sLine, 4, 8)
sPlan = Mid(sLine, 12, 10)
sPolicy = Mid(sLine, 22, 15)
sTax_qualifier = Mid(sLine, 50, 4)
sTrx = Mid(sLine, 54, 4)
sTrx_desc = Mid(sLine, 58, 30)
sAcct = Mid(sLine, 88, 25)
sMisc = Mid(sLine, 113, 40)
sDR = Mid(sLine, 153, 16)
sCR = Mid(sLine, 169, 16)
sState = Mid(sLine, 185, 2)
sMemo = Mid(sLine, 187, 2)
sFund = Mid(sLine, 240, 4)
sRev = Mid(sLine, 244, 1)
sCat = Mid(sLine, 245, 2)
rstEnabler.AddNew
End If
rstEnabler.Update
Loop
Close 1
rstEnabler.Close
MsgBox " Records have been imported", , "Enabler.seq Record Importer"
End Sub