473,398 Members | 2,389 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,398 software developers and data experts.

Error when compact/repair on start-up

My client has asked if it's possible to Compact and Repair his Front
End database programmatically. I remember doing this from a VB
application about 10 years ago, so I wondered if it was possible in
Access.

The application is Access 2003 in 2002-2003 File Format.

I've added the following function to the Front End in a global module:

Public Function CandRDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and Repair Database..."). _
accDoDefaultAction

End Function

and created an AutoExec macro that only calls this function. It
appears to be working (something happens, there's an hourglass cursor
for example) but then barfs with the following:

"-2147467259 Method 'accDoDefaultAction' of object
'_CommandBarButton' failed"

From what I've read, this can happen if the Menu Bar is not visible,
but it is.

Any thoughts? I know that the database can be set to compact on exit,
but that's not what the client has asked for.

Thanks

Edward
Jul 2 '08 #1
5 2202
<te********@hotmail.comwrote in message
news:3f**********************************@k37g2000 hsf.googlegroups.com...
My client has asked if it's possible to Compact and Repair his Front
End database programmatically. I remember doing this from a VB
application about 10 years ago, so I wondered if it was possible in
Access.

The application is Access 2003 in 2002-2003 File Format.

I've added the following function to the Front End in a global module:

Public Function CandRDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and Repair Database..."). _
accDoDefaultAction

End Function

and created an AutoExec macro that only calls this function. It
appears to be working (something happens, there's an hourglass cursor
for example) but then barfs with the following:

"-2147467259 Method 'accDoDefaultAction' of object
'_CommandBarButton' failed"

From what I've read, this can happen if the Menu Bar is not visible,
but it is.

Any thoughts? I know that the database can be set to compact on exit,
but that's not what the client has asked for.

Thanks

Edward
You need to perform the compact from a separate database, otherwise you're
attempting to compact a file with running code, which obviously cannot be
allowed.

Create a new database file and create a public function that reads:

SourceFile = "c:\PathToExistingDatabase\MyFile.mdb"
OutputFile = "c:\PathToExistingDatabase\MyFile1.mdb"
Application.CompactRepair SourceFile, OutputFile

Kill SourceFile
Name OutputFile As SourceFile

With Application
.FollowHyperlink SourceFile
.Quit
End With

That will compact your app, then run the app and shut itself down.

Jul 2 '08 #2
if your database is too stupid to be stable-- then move to something
that is.

SQL Server works perfect for me-- I never have to compact and repair.

I believe that 'Auto-Shrink' is enabled by default on smaller editions
of SQL Server

-Aaron

On Jul 2, 5:15*am, teddysn...@hotmail.com wrote:
My client has asked if it's possible to Compact and Repair his Front
End database programmatically. *I remember doing this from a VB
application about 10 years ago, so I wondered if it was possible in
Access.

The application is Access 2003 in 2002-2003 File Format.

I've added the following function to the Front End in a global module:

Public Function CandRDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and Repair Database..."). _
accDoDefaultAction

End Function

and created an AutoExec macro that only calls this function. *It
appears to be working (something happens, there's an hourglass cursor
for example) but then barfs with the following:

"-2147467259 *Method 'accDoDefaultAction' of object
'_CommandBarButton' failed"

From what I've read, this can happen if the Menu Bar is not visible,
but it is.

Any thoughts? *I know that the database can be set to compact on exit,
but that's not what the client has asked for.

Thanks

Edward
Jul 2 '08 #3
Ask him what is the difference between on Close and on Start-up?
Nothing can happen in between...
And no code required.
Michiel
<te********@hotmail.comwrote in message
news:3f**********************************@k37g2000 hsf.googlegroups.com...
My client has asked if it's possible to Compact and Repair his Front
End database programmatically. I remember doing this from a VB
application about 10 years ago, so I wondered if it was possible in
Access.

The application is Access 2003 in 2002-2003 File Format.

I've added the following function to the Front End in a global module:

Public Function CandRDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and Repair Database..."). _
accDoDefaultAction

End Function

and created an AutoExec macro that only calls this function. It
appears to be working (something happens, there's an hourglass cursor
for example) but then barfs with the following:

"-2147467259 Method 'accDoDefaultAction' of object
'_CommandBarButton' failed"

From what I've read, this can happen if the Menu Bar is not visible,
but it is.

Any thoughts? I know that the database can be set to compact on exit,
but that's not what the client has asked for.

Thanks

Edward
Jul 2 '08 #4
Aaron, please go play in heavy traffic!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

Jul 2 '08 #5
<te********@hotmail.comwrote in message
news:3f**********************************@k37g2000 hsf.googlegroups.com...
My client has asked if it's possible to Compact and Repair his Front
End database programmatically.
Why would you ever want to do this? If the client starts with a new,
pristine copy of the FE copied from a server location to the local drive
then it's not necessary, ever.

Keith.
www.keithwilby.com

Jul 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Danny McCarthy | last post by:
I have an access database that I am having some serious problems with. In one of the Tables some records appear to contain "#error" and others "#deleted". Also when i then go neaqr a "#error" i...
4
by: linda williams via AccessMonster.com | last post by:
The code creating the recordset that is commented out below works on all my user's machines except two. What is especially irritating is that this code did work on one of their machine for several...
4
by: Wayne | last post by:
Does "Compact On Close" do a "Compact and Repair" or just a compact. Is a compact necessary (or at least a good idea) on a regular basis, say weekly, for a database that has several hundred records...
5
by: SheldonMopes | last post by:
Here is my situation:I have several Access database projects that all keep their back-end data in a directory on a server. I would like to have a small Access application that could open each .mdb...
2
by: bobdydd | last post by:
Hi Everybody For Microsoft Access 2000 and above Windows XP I am trying to mimic the action of this command that at the moment runs from the start>>all programs at the bottom left of the...
3
by: G Gerard | last post by:
Hello The more I use an application ( an mdb) created using MSAccess I notice that the Byte size of the application keeps on increasing. Once in a while I do a Compact and Repair Database...
8
by: Jeff | last post by:
I have a db that has a couple of times closed Access completely when Saving work. So I usually compact and decompile and this seems to fix the problem. But not his time. It has come back again....
6
by: Roger | last post by:
if I make a copy of northwind.mdb sample and import data till it reaches 350Gb in size and then I make a second copy of northwind then I open nw1.mdb and do a compact / repair that takes 30-60...
3
by: christianlott1 | last post by:
I wouldn't have brought this up except that a friend had a similar problem as well. Situation: Code works fine for months, then suddenly breaks. In my case the code broke on a piece of...
5
by: prakashwadhwani | last post by:
The Delete Event/Proc & "Save_Fields_In_Form_Header" Event/Proc in my form were working perfectly. However, after I added a call to the "Save_Fields_In_Form_Header" Event/Proc in the...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.