I've been struggling for days and can't seem to get my code to work properly. I have an Access2007 db into which I want to import monthly my Vonage activity using a form with a button. For some reason, no records are imported when the button is clicked. Below is my vba code, table layout, and sample records from the Vonage activity csv input file.
Any help will be greatly appreciated.
My Code:
Private Sub cmdVonageStmt_Click()
DoCmd.Hourglass True
CurrentDb.Execute "DELETE * FROM VonageStmt;"
lblVonageStmt.Visible = False
txtVonageStmt = ""
Dim rs1 As DAO.Recordset
Dim FileName As String
Dim FileDate As Date
Dim FileNum As Integer
Dim strFilter As String
Dim strFileDesc As String
Dim strFileExt As String
Dim strRecord As String
Dim strRecordArray() As String
Dim intCount As Integer
Dim InputString
FileName = ahtCommonFileOpenSave( _
InitialDir:="C:\Users\jhrAcer\Downloads\Vonage", _
Filter:=strFilter, _
OpenFile:=True, _
DialogTitle:="Select File for Import... *.csv", _
Flags:=ahtOFN_HIDEREADONLY)
FileDate = FileDateTime(FileName)
FileNum = FreeFile()
Set rs1 = CurrentDb.OpenRecordset("VonageStmt")
DoCmd.RepaintObject acForm, "FrmMainMenu"
DoCmd.Hourglass True
Open FileName For Input As #FileNum
Line Input #FileNum, InputString
strRecordArray = Split(InputString, ",", 4)
On Error Resume Next
Do While Not (EOF(FileNum))
If strRecordArray(1) <> "null" Then
rs1.AddNew
rs1.Fields("DtTm") = strRecordArray(0)
rs1.Fields("Type") = strRecordArray(1)
rs1.Fields("Number") = strRecordArray(2)
rs1.Fields("Length") = strRecordArray(3)
RecCnt = RecCnt + 1
rs1.Update
End If
Loop
rs1.Close
Close #FileNum
DoCmd.Hourglass False
lblVonageStmt.Visible = True
txtVonageStmt = RecCnt
End Sub
===========================
VonageStmt Table
DtTm Text 255
Type Text 255
Number Text 255
Length Text 255
===========================
YY-MMDD.csv Downloaded File
Date/Time,null,Number,Length,Cost
12/20/2012 12:11 PM,Forwarded,BANK OF AMERICA (949) 994-7496,00:32,--
12/20/2012 09:03 AM,Forwarded,BANK OF AMERICA (949) 994-7496,00:03,--
12/14/2012 02:34 PM,Outgoing,(781) 975-7822,01:43,--
12/14/2012 11:10 AM,Incoming,TOLL FREE CALL (866) 294-1503,00:09,--
12/14/2012 10:15 AM,Outgoing,(708) 695-6619,00:14,--
12/12/2012 11:41 AM,Incoming,TOLL FREE CALL (866) 854-3732,00:04,--