[AccessD] Problem Exporting to a CSV file with a Column Name that has a #

Stuart McLachlan stuart at lexacorp.com.pg
Tue Apr 19 22:40:09 CDT 2011


The best solution is not to use the built in Access export routine.  Roll your own and you can 
put anything you want in the file.

Aircode:

Function Export() as Long
Dim rs as DAO.Recordset
Dim ff as long
ff = Freefile
set rs = CurrentDB.Openrecordset("qryMyExport")
ff = Freefile
Open "myExportFile.csv" for Output as #ff
Print #1,"First fieldname,Employee #,Third fieldname"
While not rs.Eof
   Print #1 rs(0) & "," & rs(1) & "," & rs(2)
   rs.movenext
Wend
Close #ff
End Function

-- 
Stuart

On 19 Apr 2011 at 17:23, Brad Marks wrote:

> All, 
> 
> We are just starting to use an Access 2007 application to feed data to
> another outside system via a CSV file. 
> 
> This outside system is very rigid and we need to use exact field names
> on the CSV file that we are creating.
> 
> The catch is that one of the fields is call "Employee #".
> 
> We set up an Export Specification (called Export-Query1 for our
> testing) and we are using the following command to do the export
> 
> DoCmd.RunSavedImportExport "Export-Query1"
> 
> When we run the application, everything works nicely, except the field
> named "Employee #" is somehow being renamed "Employee ." in the
> generated CSV file.
> 
> We have run a number of tests and it looks like we have stumbled upon
> either a "bug" a "feature", or something that we just don't
> understand.
> 
> Is there a way to force Access to not replace the "#" with a "."  ?
> 
> Thanks for your help,
> 
> Brad 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 






More information about the AccessD mailing list