Process won't run second time in ACCESS 2003

I have a form in an ACCESS 2003 database from which the user can select days to create am Excel 2010 workbook.  They can select, say, all the Month of May, run the process to export the data to Excel.  However, if they select another month, say March, then run it again, the process fails.  It throws Error Number 91, Object variable or With blcok variable not set.  This is a show stopper and I have no idea what to look for.

Sandra
Sandra SmithRetiredAsked:
Who is Participating?
 
clarkscottConnect With a Mentor Commented:
"Object variable or With blcok variable not set" means you are trying to access an object that is "no longer there".  You may want to close your Excel app completely when finished, then run he whole thing again when you want to do another.
Put all you Excel code (dims, open, close, etc.) in a function and pass the necessary info to the function each time.
Scott C
0
 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPConnect With a Mentor Commented:
How are you creating the Excel Workbook?

It would help to see the VBA you are using.

If you are using Automation you might have an issue with Excel not getting terminated properly.
0
 
Kelvin SparksConnect With a Mentor Commented:
Also check what object you shut at the end that may have been opened prior to the first session. Probably identified by .Quit

Kelvin
0
 
Sandra SmithRetiredAuthor Commented:
Yes, that was it.  All suggestions contributed to the solution.  Thank you as this was a real problem.

Sandra
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.