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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PRoblems importing csv file

Status
Not open for further replies.

timotai

Technical User
Apr 13, 2002
119
GB
Hi

i am trying to import a number of csv files using the following code:

Code:
StrSql = "SELECT Functions.Order, Functions.Function AS func FROM Functions WHERE (((Functions.Function)<>'SQLdwndone')) " & _
"ORDER BY Functions.Order;"
Set db = CurrentDb
Set rst = db.OpenRecordset(StrSql, dbOpenSnapshot)
SQLfunc = rst("func")


Do Until rst.EOF
SQLfunc = rst("func")
Eval SQLfunc & "()"
    
DoCmd.TransferText acImportDelim, "", SQLfunc, "C:\temp\Profile_Data\" & SQLfunc & ".csv", True, ""

rst.MoveNext
    
Loop

This is a line from one of the csv files:

S0000001,PROPERTY ,DUPLICATE ,N,N,N

When the files are imported into tables instead of the userid (which is S0000001) showing as it is it is changed to £1.00!

I have tried to mess about with the code to force it to accept the data as it is with no luck.

Does anyone have an idea what I can do to stop access changing the data?

Thanks
Tim
 
manually import the csv file, during the import wizard click the advanced button, there it will allow you to set the data types for the import fields, then save the spec. then reference the saved spec in the import code:

DoCmd.TransferText acImportDelim, "Your Import Spec", SQLfunc, "C:\temp\Profile_Data\" & SQLfunc & ".csv", True, ""
 
My problem then is that I am passing several csv files through the same piece of code. they have different number of fields and the data type in each field may be different to the other csv files. Am I right in assuming this spec would be specific to the csv?

Thanks

Tim
 
Are you importing to an existing table? Try to import to an existing table with that field set to text and see if you get the same results.

Remember, wherever you go...there you are.
 
What I am getting now is the number being drag through but only as 1 instead of S0000001. I don't understand why it won't just pull the data through as it is presented to it.

I have the field set to text so its not changing at that point.

Thanks everyone so far for your help!

More is required.

Thanks

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top