Link to home
Start Free TrialLog in
Avatar of julescantwell
julescantwell

asked on

Importing from Excel to Access - need to handle exceptions

I have inherited an Access database from someone I no longer have contact with. There is a form which the user uses to import access spreadsheets into the db, with each worksheet in the spreadsheet going to a certain table based on its name.

If I try to import a file when Excel is open, even if it's not actually that file that is open, it basically crashes. I think I have identified where the exception handling code should go, but how do I handle this problem?

Also, I have a separate issue when I click the Append button to copy the imported data from the Import tables to the data tables - I get a few prompts asking me to enter values for certain fields. I believe this happens when those fields are missing, but it's not a problem if they are missing. Also, I can import say, 5 sheets from one file to 5 different import tables, and then click Append at the end to copy the data in all 5 import tables to the relevant tables, but even if I only import 1 table, for which I know there are no missing fields, I still get a prompt to enter fields from other tables.

There is one macro mcrImport which is triggered by the Append button, and it calls several queries which copy data from the import tables to the data tables. Any idea how I can get rid of the prompts?

Also, if the user accidentally selects a worksheet with a header row only and no data rows, when they try to import it, it goes into what seems to be an infinite loop. Is there code I can add to handle this case?

Many thanks.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial