1

I tried to save such a csv file in a table:

XValue, YValue, Wert, Name, FzgID
, ,  "CARB (Evap Denom)",  DIUMPR_CldStrtDenCldStrtTyp_C, 238
, , 800.0000000000000000,  DIUMPR_ctGen.l500MD_C, 238
, , 10000.0000000000000000,  DIUMPR_ctGen.l500MDInc_C, 238
, , 600.0000000000000000,  DIUMPR_ctGen.nIgnMin_C, 238
, , 740.0000000000000000,  DIUMPR_ctGen.pEnvMin_C, 238
, , 5.0048828125000000,  DIUMPR_ctGen.rAPPMax_C, 238

I am using this code:

DoCmd.TransferText acImportDelim, , "tb_DCM_Daten", Filename, True

My problem is, for the first row in csv file. It doesnt save CARB (Evap Denom)" in Wert field in the table. other rows are saved without any problem.

If I have a cvs file with only one row like this:

     XValue, YValue, Wert, Name, FzgID
    , ,  "CARB (Evap Denom)",  DIUMPR_CldStrtDenCldStrtTyp_C, 238

this row will be saved correctly in the table in database also with "CARB (Evap Denom)"

could someone say me the cause of this event?

Kaja
  • 2,962
  • 18
  • 63
  • 99

1 Answers1

1

You have omitted the second argument to the TransferText method. That argument is the SpecificationName, which is the name of an Import Specification that tells Access what the field names and types are supposed to be for that particular import.

Without an Import Specification, Access will look at the first few lines of the CSV file and "guess" at what the field types should be. In your case - except for the first line of data - [Wert] looks like a numeric field, so that is what Access creates. The value from the first data line does not get imported because it is not suitable for a Number (Double) field.

You have at least two options:

(1) You can create an Import Specification by performing a manual import in Access, clicking the "Advanced..." button, tweaking the Field type(s), and clicking the "Save As..." button ...

ImportSpec.png

... then including the name of the Import Specification as the second argument to your TransferText call:

DoCmd.TransferText acImportDelim, "DCM Import Specification", "tb_DCM_Daten", Filename, True

... or ...

(2) You could create the table (with the appropriate field names and types) first, and then import the CSV file into the existing table.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418