Connecting Tech Pros Worldwide Help | Site Map

Error when compact/repair on start-up

  #1  
Old July 2nd, 2008, 01:25 PM
teddysnips@hotmail.com
Guest
 
Posts: n/a
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
  #2  
Old July 2nd, 2008, 02:15 PM
Stuart McCall
Guest
 
Posts: n/a

re: Error when compact/repair on start-up


<teddysnips@hotmail.comwrote in message
news:3f682b03-63d9-49a5-a95f-093f742b8074@k37g2000hsf.googlegroups.com...
Quote:
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.



  #3  
Old July 2nd, 2008, 03:15 PM
a a r o n _ k e m p f
Guest
 
Posts: n/a

re: Error when compact/repair on start-up


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:
Quote:
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
  #4  
Old July 2nd, 2008, 03:35 PM
Michiel Rapati-Kekkonen
Guest
 
Posts: n/a

re: Error when compact/repair on start-up


Ask him what is the difference between on Close and on Start-up?
Nothing can happen in between...
And no code required.


Michiel


<teddysnips@hotmail.comwrote in message
news:3f682b03-63d9-49a5-a95f-093f742b8074@k37g2000hsf.googlegroups.com...
Quote:
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
>
  #5  
Old July 2nd, 2008, 03:45 PM
Linq Adams via AccessMonster.com
Guest
 
Posts: n/a

re: Error when compact/repair on start-up


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

  #6  
Old July 2nd, 2008, 03:55 PM
Keith Wilby
Guest
 
Posts: n/a

re: Error when compact/repair on start-up


<teddysnips@hotmail.comwrote in message
news:3f682b03-63d9-49a5-a95f-093f742b8074@k37g2000hsf.googlegroups.com...
Quote:
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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
File / Record Lock Error !! prakashwadhwani@gmail.com answers 5 March 4th, 2008 12:55 PM
Disk Or Network Error NEWSGROUPS answers 18 January 9th, 2007 01:35 AM
A mystery: can just a compact & repair change table relationships? GaryDave answers 6 November 13th, 2005 11:44 AM
Best way to repair corrupted VBA code module? Lauren Wilson answers 14 November 13th, 2005 09:47 AM
where I made mistake on compact the current database? Paul T. Rong answers 3 November 13th, 2005 12:47 AM