473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to compact and repair access 2010 database from form on button click

I am hiding title bar and file button on it,because of which user can not compact and repair database.so want to create button on form using which user can compact and repair.
I tried code.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdCompact
  2.  
But it gives error that instead of code/macro do it from file menu
so what code i should write and is it possible
Thanks in advance
Nov 22 '13 #1
4 5682
zmbd
5,501 Expert Mod 4TB
If you are trying to do this on the open database this will error because the database has to be closed. When you do this from the command/ribbon, the Program closes the file and does its magic. When you try to do this from VBA, the file closes, and then the Program forgets what it was doing...

The only ways I can see that you could potentially do this is to start another instance of the Access application that had code to check that the calling application has closed, then you could potentially call the C&R or maybe shell out run a script.

You really should not need to C&R a live database if it is properly designed. If you are importing and deleting a lot of data, then I would suggest that you split the database out. You can then then do some magic with that backend database file.

(you'll find one discussion about this here: http://bytes.com/topic/access/answer...base-using-vba as you can see it's not something that is easily done)
Nov 25 '13 #2
zmbd
5,501 Expert Mod 4TB
as this thread popped up again due to spamming:

Please do not post commercial solutions/programs in answer to this thread - such posts will be deleted and the poster's account may be banned (either short term or permanently) for violating the terms of use for this site.
Mar 29 '14 #3
thanks z
i simply checked the box compact on close in
File>>Options>>Current databse>>Application options

it works well for me i also split the database from your suggestion
regards
Aug 28 '14 #4
zmbd
5,501 Expert Mod 4TB
rahul2310

Auto Compact and Repair has had issues and caused corruption in databases both the FE and the BE. If you are having alot of database bloat then there is something wrong with your application and Auto Compact and Repair may just make it worse. Instead, you need to find the source and restructure the code and tablses so that you do not get that kind of bloat. You can start a new thread and tell us about your application and we may be able to help you avoid the bloat.
Aug 28 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Cillies | last post by:
Hi, I want to display the number of records in a form on an access 2002 database. I know that under properties you can select navigation button, which allows the user to flick through the...
6
by: VivDenham | last post by:
I have a Form, the fields of which I also use to copy and paste into a Report. However, each time I make design changes to the Form, I have to remember to copy and past the changes into the Report....
0
by: araman | last post by:
Hello, I have a form and subform . The Main form contains four boxes to enter criteria for the query that fills the subform. Outside of the navigation form it works great. when i add it to the...
2
by: kittycatt | last post by:
Hi there New to all this and have no programming experience. Basically I am a volunteer and currently offering my I.T skills of Access to design a database to record client details. All clients...
5
lilp32
by: lilp32 | last post by:
I need to connect to a password protected Access database through Excel. Everything I've found while searching seems to imply that this is a bug that Microsoft has not fixed. Is this true? The...
3
Hothmire
by: Hothmire | last post by:
Good afternoon I am new to being a programmer and i am trying to make a button on an MS Access form that will navagate to a table that has a hyperlink in one of its records. I want to navagate to...
0
by: ammounn | last post by:
i'm publishing my vb 2008 application using an access database but the problem is after publishing it wont run and it display an error message that the database was not found although i added it in...
2
by: Redbeard | last post by:
I need to save my Access 2010 database in 2003 format so that someone can use it that is only running 2003. My database was built using Access 1997 and has been upgraded over the years to 2003, 2007...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.