Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import spec (2002)

    Here's my problem.

    I have two types of .csv files that I need to programatically import into access. I'm using an import specification for each file, the first row of each file contains some of the exact field names for respective access target tables. Each file may or may not contain all the fields in the target table, but all NOT NULL fields are always present. The target tables share some common field names, but there's at least one distinct field name between the two target tables and source files. Is there a way to validate the field names during Import? I can import SourceFileA into TargetTableB using FileSpecA with no error. I pasted the transfertext command I'm using below.

    DoCmd.TransferText acImportDelim, "spc" & strTargetFile & "_stg", "tbl" & strTargetFile & "_stg", strPath, True

    I'm trying to do this without writing a ton of VBA,but I don't see a way to validate field names with TransferText. Any help is appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import spec (2002)

    You could open the .csv file first using the old Open instruction, read its first line using Line Input, and parse the line to determine the field names. Then Close the file, and use TransferText with the appropriate import specification.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import spec (2002)

    Works great, thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •