Avatar of cipriano555
cipriano555
 asked on

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
Microsoft AccessVBA

Avatar of undefined
Last Comment
cipriano555

8/22/2022 - Mon
Jim Dettman (EE MVE)

Just use CurrentProject.Connection   There is no need to use cnDest .

Jim.
Rey Obrero (Capricorn1)

are you closing the cnDest after using it?

cnDest.close
cipriano555

ASKER
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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cipriano555

ASKER
I got rid of cnDest and just used CurrentProject.Connection directly, problem solved.