Exporting CSV Data

khwaja

Registered User.
Local time
Today, 20:27
Joined
Jun 13, 2003
Messages
254
I would like to export the contents of a table in CSV format and email to a recepient regularly. As I understand, this can be achieved to create text files but not quite csv. I used the following code to create txt attachment. Could someone help me amend this code to attach CSV format.

Private Sub Command0_Click()

On Error GoTo Err_Command0_Click
Const FILE_SPEC As String = "C:\Temp\File.txt"
Const TABLE_NAME As String = "tblPtojects"


DoCmd.SendObject acTable, "tblProjects", acFormatTXT, "Email Address", , "Design Variations", "Attached is the report showing all design variation requests that have been approved over the past three months." & _
vbCrLf _
& vbCrLf & "Cheers" & vbCrLf _
& vbCrLf & "AK", True

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

--------------------
Regards

Arshad
 
Const FILE_SPEC As String = "C:\Temp\File.txt"

DoCmd.SendObject acTable, "tblProjects", acFormatTXT, "Email Address", , "Design Variations", "Attached is the report showing all design variation requests that have been approved over the past three months." & _
vbCrLf _& vbCrLf & "Cheers" & vbCrLf _& vbCrLf & "AK", True

You might try changing \file.txt to \file.csv and
acFormatTXT to acFormatCSV

Hth
 
Thanks. I tried but getting error as somehow it does not like acformatcsv as the valid expression.
 
OK, let's try something different :
To export a table , click the table in the DB, go to file>export , put in a filename and select text files (*.txt, *.csv, etc) in save as type. Hit : export button.

You will now get the export text wizard, which you can use to define data type etc.
In the last screen , you will see something like :

Export to file
C:\Yourtable.txt

Change that to C:\Yourtable.csv


Hth
 

Users who are viewing this thread

Back
Top Bottom