Roy wrote:
On Oct 10, 2:42 pm, Salad <o...@vinegar.comwrote:
>>Roy wrote:
>>>Hi all,
I have a strange request.A client of mine has a data from text file
which has to be imported and calculations done.This is fine and works
good.But one of the fields is named Dept. with the period.Because of
Access,this (.) period is eliminated while importing.He wants the
period to appear on the field name in the export file.Is this
possible?
>>>Thanks,
>>>Roy
If it can't be done via the Export, you can always write out the file
easily enough and do whatever you want.
See Open, Print, Put, Write, Close in help.
is it possible to elaborate on this,any example?
Thanks,
Roy
I don't know if this will create a "true" command delimited file....it
puts quotes around everything. Change the output filename and the
recordset and run a test. In the header/col part you'd check to see if
the name is "Dept" and change it to "Dept."
Sub PrintTest()
Dim strFile As String
Dim rst As Recordset
Dim intFor As Integer
Dim intRst As Integer
Dim strOut As String
Dim Quote As String
Quote = Chr(34)
'Change the output name
strFile = "C:\Junk\Junk.Txt"
Open strFile For Output As #1
'Change to your table name
Set rst = CurrentDb.OpenRecordset("Table1")
'print column headers and first 5 records
For intFor = 0 To 5
strOut = ""
If intFor = 0 Then
'create the header/column name line
For intRst = 0 To rst.Fields.Count - 1
strOut = strOut & Quote & rst(intRst).name & Quote & ","
Next
Else
'create the data lines
For intRst = 0 To rst.Fields.Count - 1
strOut = strOut & _
Quote & rst(intRst).Value & Quote & ","
Next
End If
strOut = Left(strOut, Len(strOut) - 1)
Print #1, strOut
rst.MoveNext
Next
Close #1
rst.Close
Set rst = Nothing
End Sub