Access VBA application: Placed in a State that prevents it from being opened or locked

I am developing an Access 2013 application. In testing, the first time I run through my process, it works. When I try to run the application a second time, I get the message,   "The database has been placed in a state...that prevents it from being opened or locked."  

I am developing this on my laptop.  There is no network, or multiple users involved.  The application retrieves data from a SQL Server database and copies it into an Access table.   The error shown in the attached image occurs at this statement:   cnDest.Open CurrentProject.Connection

  Dim cnDest As New ADODB.Connection
 cnDest.Open CurrentProject.Connection

If I close access and open it up again, the error is gone and I can run the process again...but that is not a fix for the problem.  I researched on the web...nothing conclusive.

Thanks for your help
PlacedInAStateError.JPG
cipriano555Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Just use CurrentProject.Connection   There is no need to use cnDest .

Jim.
Rey Obrero (Capricorn1)Commented:
are you closing the cnDest after using it?

cnDest.close
cipriano555Author Commented:
Yes, I close it...the end of my procedure has

SourceRs.Close
Set SourceRs = Nothing
cnDest.Close
Set cnDest = Nothing

I will try to redo things without even using cnDest
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Keep in mind that the point of using CurrentProject.Connection is that you get to use Access's own ADO connection object, so you don't need to do your own.

If you want your own because you want to change the connection properties, then you'd specify the provider and all the properties, not use Access's connection.

Jim.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cipriano555Author Commented:
I got rid of cnDest and just used CurrentProject.Connection directly, problem solved.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.