Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Excel file into Access table keeping old data/adding new. 2

Status
Not open for further replies.

Sherman6789

Programmer
Nov 12, 2002
127
US
I have an Access table that needs to be updated every two weeks. The update information comes from an Excel spreadsheet with the same headings in the same order as the Access table. The Excel table is not formated. For example: phone in Excel is 2025551212. The format in Access is (202) 555-1212. The new data coming from the Excel file always brings the old data as well as the new data. Example: the original file may have had 25 records the first week. The next update may be 28 records. The original 25 records unchanged plus 3 new records. The third update may 50 records with 28 old records (25+3 unchanged records) and 22 new records. There is a key field which is NOT and should not allow duplicates. The old table has six (6) fields that are not on the Excel file. The information in these six fields are added manually to the Access table throughout the week.

When the Excel file is added to the "current" old Access Table, the added fields must not be modified. When the new data is merged into the old file, the old data from the Excel file should be ignored, if possible. If they can not be ignored and must replace the old data; that's OK provided the six fields are NOT altered. The Access file's key field will not allow duplicates which is great. However, when I try to import external data from the Excel file, the old data is overridden with the same data from the new table and the new records are added to the file as it should. The problem is that a brand new table is created which contains all of the data from the old and the new but this brand new table does not contain the six fields that were on the old Access file and I must add them each time to the brand new table. When I try to have the data only update the old table, I get an error. It seems to work only if I let Access create a new table. If won't work if the table is open and if the table is closed, it causes an error.

The ideal solution is to have the Excel file merge with the old Access table (with the six extra fields unchanged); new data is added; old files that match the key field are ignored and the same table remains the resulting table. The old table is important because there are several forms and reports that reference the old table name.

I would have less trouble if both table were Access but I don't have that choice. If I frist convert the Excel table into Access, I then have to set the format and make an update query or append in some way. This cause for too many steps unless it was a simple program or macro.

I hope that this is not too long and I've tried to cover all the details that I think you need. The users of the file are not very familar with Access. I know enough to be dangerous but I can follow directions ok and have a pretty good knowledge of general Access information.

Any help will be appreciated.

 
I would have less trouble if both table were Access
You may consider linking the Excel sheet to an access table
or transfer the spreadsheet to a brand new temporary table.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV,

The Excel spreadsheet is created automatically from a huge government database that I have no control over. The users that will be operating this procedure needs as few steps as possible.

I have to eliminate the possibility of linking because a new spreadsheet is created each time. The table is given a different numerical name each time by higher ups from a different department.

Also, I would rather not transfer the table from a spreadsheet to a temporary table unless it can be done automatically with minimal effort on the user's part.

WRS
 
Take a look at the DoCmd.TransferSpreadsheet method

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
To PHV,

Hello again. How do I get to "DoCmd.TransferSpreadsheet method"?

I went to Help and typed "DoCmd.TransferSpreadsheet" and "Transfer Spreadsheet". What I got was "Transfer Spreadsheet Action". This may be helpful. I am reading it now. I decided to ask where to get the info, so I can print it out and read it at home tonight. Thanks!

WRS
 
What you've got is a macro help.
You may consider using VBA (Alt-F11) and consult the object browser (F2) and/or the VBA help (F1).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top