Pages

Showing posts with label Export Table To Csv File. Show all posts
Showing posts with label Export Table To Csv File. Show all posts

Wednesday, December 28, 2011

Export Table To Csv File

If you want to export access table to CSV file .

Here is the code-


Sub export_table_as_csv()
DoCmd.SetWarnings (False)
Dim importtable As String
Dim exportfile As String
importtable = "sales_detail"
' complete path with csv file name
exportfile = "C:\Documents and Settings\user\Desktop\acess tutorials\28 dec 2011\sales_detail.csv"

' check if the any csv file aready exists with same name
If Dir(exportfile) <> "" Then
MsgBox "File already exists"
Exit Sub
End If
' convert table to csv
DoCmd.TransferText acExportDelim, TableName:=importtable, FileName:=exportfile, HasFieldNames:=True
DoCmd.SetWarnings (True)
End Sub


Download Access Database