How do I export a table to text without CR/LF. I need a flat file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My table has 22 94-byte records. I need to export to a single 2068-byte
record that doesn't contain any CR/LF.
 
Air code, using the WriteToFile() function at
http://www.j.nurick.dial.pipex.com/Code/index.htm

Dim rsR as DAO.Recordset
Dim S As String
Dim ErrorCode As Long

Set rsR = CurrentDB.OpenRecordset("MyTable")
With rsR
Do Until .EOF
S = S & .Fields(0).Value
Loop
.Close
End With

ErrorCode = WriteToFile(S, "C:\Temp\Myfile.txt")

If ErrorCode <> 0 Then
MsgBox "Something went wrong."
End If



On Tue, 20 Jun 2006 13:51:02 -0700, Mark Beer <Mark
 
Um, no offense John, but wouldn't it be sporting to provide them with the
code for WriteToFile as well? <g>
 
We ran into a problem with one line of your solution. We corrected it as
follows and everything works now. Thank for your help.

Here's the revised code:

Function WriteToText(ByVal tableName As String, ByVal exportLocation As
String)

Dim rsR As DAO.Recordset
Dim S As String
Dim ErrorCode As Long
Set rsR = CurrentDb.OpenRecordset(tableName)
Do Until rsR.EOF
S = S & rsR.Fields(0).Value
rsR.MoveNext
Loop
rsR.Close
ErrorCode = WriteToFile(S, exportLocation)
If ErrorCode <> 0 Then
MsgBox "Something Went Wrong"
Else
MsgBox "Export Complete"
End If
End Function
 
Back
Top