Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Posts
    38

    Unanswered: Export a Table as CSV and send via email

    I would like to export the contents of a table in CSV format and email it to a recepient regularly. As I understand, a text file can be createed but not quite csv. I used the following code to create txt attachment. Could someone help me amend this code to attach in 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 Variationss", "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

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    CSV files CAN be created from Access Tables - really easily too!

    Simplest way is to create a Macro...
    Action: TransferText
    TransferType: Export Delimited

    This is also available in VBA
    Code:
    DoCmd.TransferText
    Told you it was easy
    George
    Home | Blog

  3. #3
    Join Date
    May 2006
    Posts
    38
    Thanks George. Macros are pretty basic. I need a single VB statement to create a CSV and then email with pre defined text. Are you able to help?

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Can't be done in a single statement but it can be done in a single procedure.

    I advise you start by creating a macro to do it that works, then right click the macro and 'Save as...' module! This'll send it to a module in VBA!

    How good is that?!
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •