Importing Text Problem

B

Bre-x

Hi,
I have a csv file with the following content

2009-07-13,34195,1,CI000139,3,A

When I import it into ms accesss with:

'Import Text File
file_name = "M:\Reorder\toolcrib\toolcrib.csv"
DoCmd.TransferText acImportDelim, "", "Temp", file_name, False, ""

the first column (2009-07-13) is imported as a date and change it to
'7/13/2009'

I dont want that to happen, I need this column to be imported as text and
as '2009-07-13'

Any ideas?

Thank you all!!!!!

Bre-x
 
J

John Spencer

Set up and save an import specification that defines the field types.

You can set up an import specification by doing a manual import

==File: Get External Data: Import
==Choose the text file
==Follow the on-screen instructnions
==Set up the field specifications
==Click the advanced button
==When you have the specifications set up click the Save As... button to save
the specification

Now when you use DoCmd.TransferText use the name of the import specification
as the second argument.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
B

Bre-x

John Spencer thank you for answering my post!!

But i decide to take another way.

Public Function mydate(the_date As String) As String
mydate = Format(the_date, "YYYY") & "-" & Format(the_date, "MM") & "-" &
Format(the_date, "DD")
End Function

Thank you again!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top