简体   繁体   中英

Importing from Excel to Access errors

I am trying to find help to an Access Error I receive when Importing from an xls spreadsheet.

I am using Access 2010 and Excel 2010

The error only happens in blank cells that are formatted as Accounting with a value of 0.00 hard coded into the formula for all blank cells. I have changed the cell format to number (and the value to 0), and even replaced the values with "" (To make them null).

Before import I repaste values only (Paste special values only) over the formulas so that all the number data is value only.

For the Import I am replacing an existing table in access each time (Its the way its designed not my idea) so I am not sure if this might have any affect. When I run the import only the 0.00 number fields are put into the error table.

I have been trying to work with the .value = .value commands in VBA talked about other places on this board, but I have had no luck so far. Any help or ideas on the subject would be great.

Thank you, Daniel

First, run this code on the Excel worksheet.

sub cleanup
    dim c as long
    with worksheets("sheet1").cells(1, 1).currentregion
        for c = 1 to .columns.count
            .columns(c).cells = .columns(c).cells.value2
        next c
    end with
end sub

Set the Access monetary fields to Currency . Allow Required: No with a Default value: 0 .

The Excel worksheet cells cannot be zero-length strings (eg "" ). They have to be truly blank. That is taken care of with the short cleanup routine. The truly blank cells will come into the Access field as nulls and receive the default value of 0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM