I have a file in Excel 2010 that has fields with numbers rounded to the nearest dollar. The value has cents in it, but it is just formatted to only show whole dollars. However, I wish to import the cents into an Access 2010 table as well. I currently use the following command to import the worksheet:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strFile, True, wks.Name & "$"
For the most part, all of the values are being imported correctly. However, when there is a column where the top several rows do not have any cents, it seems that when it will not bring in the cents in the subsequent records. It will bring in the rounded number instead. I am not 100% sure, but I think there is something in Access where it looks at the top rows to determine the datatype it is importing. In this case, it seems that it thinks everything will be whole dollars and it ignores the cents.
I know that if someone manually formats the sheet to show 2 decimal places prior to importing, it will work fine. But, I am trying to eliminate the need for any modification to the original dataset. What is the best approach at doing this?
Thanks
1. Link to the spreadsheet as a table. You can then work with it that way.
2. Have the user save the spreadsheet in a CSV format (or other text format). Then you can use TransferText and specify a import specification that you've written for the import.
3. Same as #2, but link to it as a table and use a schema.ini file to describe the fields.
4. Open Excel as an automation option (Excel needs to be installed where your doing the import), and then loop through the cells and pull the data. This gives you total control.
Let me know if you need anything more...
Jim.