Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:42:15+00:00 2026-05-22T18:42:15+00:00

I am using the DoCmd.TransferText in MS-Access-2010 VBA to export a table to a

  • 0

I am using the DoCmd.TransferText in MS-Access-2010 VBA to export a table to a .csv file. However when I do this the resulting .csv file truncates the information in the table. For example the longitude -85.350223 becomes -85.35. How do I make it where the resulting .csv file is still comma delimited and keeps the full information from the table?

If I need to create an Import/Export specification and reference it in the command line using the SpecificationName feature of DoCmd.TransferText (assuming I have correctly interpreted this feature as a formatting tool) please explain how to do that.

Here is the line I am currently using to export the file to .csv:

DoCmd.TransferText acExportDelim, ,
“AllMetersAvgRSSI”,
CurrentProject.Path &
“\AllMetersAvgRSSI.csv”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:42:15+00:00Added an answer on May 22, 2026 at 6:42 pm

    I recommend you use this function taken from eraserve:

    Here’s how you use/call it:

    Call ExportToCSV("AllMetersAvgRSSI", _
                      CurrentProject.Path & "\AllMetersAvgRssi.csv")  
    

    And here’s the function:

    Public Function ExportToCSV(TableName As String , _ 
          strFile As String , _ 
          Optional tfQualifier As Boolean , _ 
          Optional strDelimiter As String = "," , _ 
          Optional FieldNames As Boolean ) As Byte
    
       'References: Microsoft Access 11.0 Object Library, Microsoft DAO 3.6 Object Library 
       'Set references by Clicking Tools and Then References in the Code View window 
       ' 
       ' Exports a table to a text file. 
       ' Accepts 
       ' Tablename: Name of the Target Table 
       ' strFile: Path and Filename to Export the table to 
       ' tfQualifier: True or False 
       'strDelimiter: String Value defaults to comma: , 
       ' FieldNames: True or False 
       ' 
       'USAGE: ExportToCSV TableName, strFile, True, ",", True 
       On Error GoTo errhandler  
    
       Dim intOpenFile As Integer , x As Integer 
       Dim strSQL As String , strCSV As String , strPrint As String , strQualifier As String 
    
       'Close any open files, not that we expect any 
       Reset 
    
       'Grab Next Free File Number 
       intOpenFile = FreeFile 
    
       'OPen our file for work 
       Open strFile For Output Access Write As # intOpenFile 
    
       'Write the contents of the table to the file 
       'Open the source 
       strSQL = "SELECT * FROM " & TableName & " As " & TableName 
    
       'set the qualifer 
       strQualifier = Chr( 34 ) 
    
       With CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot) 
    
          'Check if we need Field Names 
          If FieldNames = True Then 
    
             For x = 0 To .Fields.Count - 1 
                If tfQualifier = True Then 
                   'Write the Field Names as needed 
                   'The Qualifier is strQualifier or Quote 
                   strCSV = strCSV & strQualifier & strDelimiter & strQualifier & _ 
                         .Fields(x).Name 
    
                   'Add last strQualifier 
                   If x = .Fields.Count - 1 Then 
                      strCSV = strCSV & strQualifier 
                   End If 
                Else 
                   'Write the Field Names as needed 
                   'No Qualifier 
                   strCSV = strCSV & strDelimiter & .Fields(x).Name 
    
                End If 
             Next x 
             'Write to File 
             strPrint = Mid(strCSV, Len(strDelimiter) + 2 ) 
             Print # intOpenFile, strPrint 
          End If 
    
          'Write the CSV 
          Do Until .EOF 
             strCSV = "" 
             For x = 0 To .Fields.Count - 1 
    
                'Check for Qualifier 
                If tfQualifier = True Then 
                   'The Qualifier is strQualifier or Quote 
                   strCSV = strCSV & strQualifier & strDelimiter & strQualifier & _ 
                         Nz(.Fields(x), vbNullString)  
    
                   'Add last strQualifier 
                   If x = .Fields.Count - 1 Then 
                      strCSV = strCSV & strQualifier 
                   End If 
                Else 
                   'No Qualifier 
                   strCSV = strCSV & strDelimiter & Nz(.Fields(x), vbNullString) 
    
                End If 
             Next x 
    
             'Eliminate Back to back strQualifiers or Qualifiers if changed 
             strCSV = Replace(strCSV, strQualifier & strQualifier, "" ) 
    
             strPrint = Mid(strCSV, Len(strDelimiter) + 2 ) 
             Print # intOpenFile, strPrint 
             .MoveNext 
          Loop 
    
       End With 
    
    ExitHere: 
       'Close the file 
       Close # intOpenFile 
    
       Exit Function 
    
    errhandler: 
       With Err 
          MsgBox "Error " & .Number & vbCrLf & .Description, _ 
                vbOKOnly Or vbCritical, "ExportToCSV" 
       End With 
    
       Resume ExitHere 
    End Function 
    

    You may also have success by changing the offending fields to text fields, or simply copying them into some temporary text fields before you do the export.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using DoCmd.SendObject to send emails from MS access 2003. It opens the
I am using the OpenArgs parameter to send a value when using DoCmd.OpenForm :
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I am using Access 2003 and I have a form that collects some filtering
I'm using a Switchboard Database to run macros on multiple Access databases one after
is it possible to detect whether there is an open query using VBA in
I have such table: CREATE VIRTUAL TABLE t USING FTS3(hidden, text1, text2) I would
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.