Access ImportSpreadsheet and Wizard Give Different Default Field Names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shenkel55
    New Member
    • Mar 2008
    • 7

    Access ImportSpreadsheet and Wizard Give Different Default Field Names

    I am using Access 2003. I've been importing Excel 2003 spreadsheets using the wizard in Access for some time now. The spreadsheet does NOT have the column names in the 1st row, so the wizard names them "Field1", "Field2", etc., by default. I decided to automate the process and I am using the following line of code:

    DoCmd.TransferS preadsheet acImport, acSpreadsheetTy peExcel9, strFileName, FileSpec, FieldNamesInRow One

    The argument for FieldNamesInRow One is passed either true or false, depending on my needs

    When I pass it false, it works fine, but it names the fields "F1", "F2", etc.

    I'm looking for an answer as to why the default field names are different. And is there a setting somewhere for the import wizard's default field name assignments?

    I won't complicate it too much by adding more, but I will just say I have all of the imported files archived. It would be very useful if they all had the same field names, regardless of how they were imported.
  • Denburt
    Recognized Expert Top Contributor
    • Mar 2007
    • 1356

    #2
    You should be able to use a schema for that although you would need to use TransferText instead or first import the sheet then rename the fields.

    CurrentDB().Tab leDefs(TableNam e).Fields(Curre ntFieldName).Na me =
    NewFieldName

    As far as explaining the methodology of Microsoft..... lol Probably had different groups on different projects and they did not catch that. Since renaming the fields or using a schema can be done easily enough they probably didn't think it was a major issue. Good luck let me know how it goes.

    Comment

    Working...