View Single Post
  #4 (permalink)  
Old December 25th, 2005, 01:16 PM
Bob Bedell Bob Bedell is offline
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

quote:You may want to scrub the output a bit also, replacing single quotes in your data steam with double quotes, that sort of thing.
Not exactly what I meant to say (was trying to write SQL and talk about table exporting at the same time).

What I meant to say is that, when you export a table via the user-interface commands using either a default or a user-defined export specification, notice that your exported string values are enclosed in double quotation marks. You won’t see that behavior when programmatically exporting with BASIC I/O functions. If you want your string data enclosed in some kind of text qualifier (e.g., double quotes), you will need to concatenate the text qualifiers in code yourself.

A better example of export data scrubbing would be if your data has embedded carriage return or line feed characters (perhaps in a memo field), and you wanted to replace the CrLf stuff with, say, a single space (“ “).

Best way to add export functionality to your apps is to create a class module that handles all your text exporting. Then you can add additional functionality as you need it, simply by adding additional properties and methods to your class, while keeping it all encapsulated in one place. You can then execute an export with code like:

Sub ExportTable()

   Dim objTextExport As clsTextExport
   Set objTextExport = New clsTextExport

   ‘Set objTextExport properties
   With objTextExport
      .AppendToFile = False
      .ExcludeFields = ""
      .ExportDatabase = CurrentDb
      .ExportFilename = "C:\Export.txt"
      .ExportSource = "tblData"
      .ExportType = "ASCII"
      .FieldDelimiter = vbTab
      .IncludeFieldNames = True
      .RecordDelimiter = vbCrLf
      .ReplaceWith = " "
      .TextQualifier = Chr(34)

      ‘Call objTextExport methods
   End With

End Sub



Reply With Quote