Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7623233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:39:19+00:00 2026-05-31T04:39:19+00:00

Ok so I have to run some queries in access 07 then compact and

  • 0

Ok so I have to run some queries in access 07 then compact and repair it. I am using python and win32com to do this. The code I’m currently using is this.

import os;
import win32com.client;
DB1 = 'db1.mdb'
DB2 = 'db1N.mdb'
DB3 = 'db2.mdb'
DBR = r'db1.mdb'
access = win32com.client.Dispatch("Access.Application")
access.OpenCurrentDatabase(DBR)
DB = access.CurrentDb()
access.DoCmd.OpenQuery("1")
access.DoCmd.OpenQuery("2")
access.DoCmd.OpenQuery("3")
access.CloseCurrentDatabase()
access.Application.Quit();
os.system('copy "db1.mdb" "db2.mdb"')
access = win32com.client.Dispatch("Access.Application")
access.CompactRepair(DB3,DB2)
access.Application.Quit();
os.remove("db2.mdb")
os.remove("db1.mdb")
os.rename("db1N.mdb","db1.mdb")

The problem is that I get this error.

WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'db1.mdb'

I dont know why I am getting this error seeing as I am quiting access which should close the file. Any Idea how to fix this would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:39:20+00:00Added an answer on May 31, 2026 at 4:39 am

    Your code includes this line:

    DB = access.CurrentDb()
    

    When that line executes, CurrentDb() references db1.mdb. Then you later get WindowsError at:

    os.remove("db1.mdb")
    

    So I’m wondering if the variable DB still holds a reference to db1.mdb. Perhaps you could first try del DB before os.remove().

    Or, since your code isn’t actually using that DB variable, just get rid of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code pattern to run some queries on a third party
I have to run some mysql update queries and they take quite a long
I have some xml documents I need to run queries on. I've created some
So I have to run some python scripts on a cluster with machines for
I have this command to go to every directory and once there run some
Some of the queries I have written inside MS-Access are getting deleted automatically. And
If I have a couple of queries in Microsoft Access that I then use
I have a database of occupation titles I'm trying to run some queries on.
I have this Access database that we use to run reports. The report is
I have run into some trouble with the gd library's imagefilledpolygon() . For some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.