Results 1 to 4 of 4
  1. #1
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115

    Tricky field formats in excel imports

    Hi. I have a spreadsheet that I want to import into access. The spreadsheet is auto generated from a system.



    I am using DoCmd.TransferSpreadsheet acImport, , "SPREADSHEET", Filepath, True.

    This imports the spreadsheet but on 2 of the fields it is losing precision. Basically it is ignoring the 2 digits after the decimal place. When looking at the spreadsheet I can see that in these 2 columns there is data physically there with 2 dps. However the excel format for the field is 'number with 0 dps". When the import runs in access it just imports the number rounded to nearest whole number. I guess it is using the excel field formats to decide how to import each field. I know I could go into the spreadsheet and change the formats pre import but the person using the system is not confident in excel and may mess something else up.

    Is it possible to tell access to read the spreadsheet and retain the underlying data or tell it what formats to use per column/field. Basically override the excel formatting?

    Many thanks

    Tony

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Instead on TRANSFERSPREADSHEET method, attach the sheet as a linked table, then Append to an existing internal table.
    this table will have predefined fields. With the decimal places. (Double)

    sometimes, access guesses at what the excel sheet column format is. And fails.

    this new way, you overwrite the old XL file with the new one, then run the append.

  3. #3
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Thank you. I will have a look at how to do this. Thanks

  4. #4
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Hi ranman256. I tried the new method. It allowed me to specify the fields in the table as ccy but still did not correctly import the values. It to the rounded number and inserted it rather than keeping the 2 dp. Is there another way?
    Many thanks Tony

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-28-2015, 08:06 AM
  2. Replies: 7
    Last Post: 04-18-2014, 05:26 PM
  3. Import from Excel file fails because of date formats
    By wardw in forum Import/Export Data
    Replies: 1
    Last Post: 01-01-2014, 02:20 AM
  4. Import Excel and date formats
    By thart21 in forum Import/Export Data
    Replies: 1
    Last Post: 04-19-2011, 03:49 PM
  5. Need Frequent Excel Imports with Primary Keys
    By UMassEngineer in forum Import/Export Data
    Replies: 1
    Last Post: 03-27-2011, 10:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums