Question on Importing CSV to ACCESS with filters

  • Thread starter Thread starter Ruby Tuesdays
  • Start date Start date
R

Ruby Tuesdays

Hi I was wondering if there is a way to do the following:

I have a CSV text file with 7 fields of data. I'd like to convert it to an
Access table with some qualifier:

if(there is PPP keyword in field 3), enter YYY in field 8
else if(there is QQQ keyword in field 5), enter UUU in field 9
else if(there is RRR keyword in field 2), replace field 4 w/ the content of
field 2
else import to the corresponding field

Thanks
 
Import the file into a temporary table as is. Then use an append query to
copy the data and to create the values for the other fields into a permanent
table.
 
But how do you apply the condition?

I'm able to import the CSV into a temporary table BUT without the condition
apply to it, so I pretty much has the same data/table-structure as the CSV.

I thought it would be easier to apply those condition just before it's
imported to the temporary table, but if it easier to apply the condition
after its in the database, that would be fine too(using vba I presume).
Thanks
 
Build a calculated field in the append query for each of the extra fields
that writes either an empty string or a value into the field, depending on
whether the condition is met. For example,

Field8Value: IIf([Field3]="PPP", "YYY", "")

Field9Value: IIf([Field5]="QQQ", "UUU", "")

For the Field4 field, use a calculated field similar to this:

Field4Value: IIf([Field2]="RRR", [Field2], [Field4])
 
Back
Top