Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with outputting text from Access

Status
Not open for further replies.

nickspace

IS-IT--Management
May 2, 2005
43
US
Hi everyone,
I am outputting the contents of a recordset to a text file. This file is later used by another program to import this text. However, everytime I output the text, each recordset field that I output has double quotes("") around them. This messes up the tags that I am outputting rendering this text unreadable by the importing program. Can someone please help me eliminate these double quotes. I have pasted my code below in case it helps.

Also, once I output to this text file, I would like to rename this file (change the extension from .txt to .xtg) using code. Right now I have users doing this manually. Does this sound possible?

Thanks,
ND


With rs
Dim stringToWrite As String

If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
If .RecordCount > 0 Then
Set cdlg = New clsOpenSave
With cdlg

.Filter = "Text Files (*.txt)|*.txt"
.CancelError = True
.DialogTitle = "Save Output Files ..."
.InitDir = DIR_APP
.ShowSave

destFile = Replace(.FileName, vbNullChar, "")
destSave = Replace(.FileTitle, vbNullChar, "")
End With
Open destFile For Output As #1
For i = 0 To .RecordCount - 1
If .Fields(0) = currentCat Then
stringToWrite = .Fields(1)
Write #1, stringToWrite
Else
stringToWrite = .Fields(0)
Write #1, stringToWrite
currentCat = .Fields(0)
stringToWrite = .Fields(1)
Write #1, stringToWrite
End If
.MoveNext
Next
Close #1

End If
End If
.Close
End With
 
Print #1 doesn't do the automatic delimiting that Write #1 does.

Hope this helps
 
that worked like a charm...

thanks, earthandfire
 
Any idea about how to rename this file (change the extension from .txt to .xtg) using code?

Thanks,
ND
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top