Private Sub cmd_ReadExcel_Click()
Dim oApp1 As Object 'Excel.Application 'Object
Set oApp1 = CreateObject("Excel.Application")
oApp1.workbooks.Open "C:\Parts.dif"
'oApp1.Visible = True
oApp1.Rows("1:1").Select
oApp1.Selection.Delete Shift:=xlUp
oApp1.ActiveWorkbook.SaveAs Filename:="C:\Parts.csv", FileFormat:=xlCSV
oApp1.ActiveWorkbook.Close SaveChanges:=False
oApp1.Application.Quit
Set oApp1 = Nothing
call MaintainTransactionData
End Sub
Public Sub MaintainTransactionData()
'from
'http://www.utteraccess.com/forums/printthread.php?Cat=&Board=84&main=1694936&type=thread
Dim db As DAO.Database
Dim strSQL As String
'Set a reference to the current db
Set db = CurrentDb
'Append from CSV ...
strSQL = "INSERT INTO tblSomeTable ( [TRADE DATE], REP, REPID, [ACCOUNT/POLICY]," & _
" CUSTOMER, [REP# COMPANY], [PRODUCT NAME]," & _
" QUANTITY, [FACE AMOUNT], [GROSS COMMISSION]," & _
" [CUSTOMER SSN] )" & _
" SELECT [TRADE DATE], REP, REPID, [ACCOUNT/POLICY]," & _
" CUSTOMER, [REP# COMPANY], [PRODUCT NAME]," & _
" QUANTITY, [FACE AMOUNT], [GROSS COMMISSION]," & _
" [CUSTOMER SSN]" & _
" FROM [Text;FMT=Delimited;HDR=YES;CharacterSet=437;" & _
" DATABASE=C:\Parts.csv"
db.Execute strSQL, dbFailOnError
End Sub
|