PC Review


Reply
Thread Tools Rate Thread

compact database in VBA access 2007

 
 
SL
Guest
Posts: n/a
 
      29th Jan 2010
Hello,

I have recently upgrade to office 2007 from office 2003. To compact a
database from within the database itself, I used the follwing code.
Unfortunately it no longer works in access 2007. Is there some similar code
that will work?

Public Function FncCompactTheCurrentDB()
CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction
End Function

Thank You,
SL
 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      29th Jan 2010
On Thu, 28 Jan 2010 17:34:01 -0800, SL <(E-Mail Removed)>
wrote:

It's not recommended to compact yourself. Rather, split the database
into front-end and back-end, store the back-end on the server, and
schedule a task to compact it ever so often, for example using the
/compact switch to msaccess.exe.

-Tom.
Microsoft Access MVP


>Hello,
>
>I have recently upgrade to office 2007 from office 2003. To compact a
>database from within the database itself, I used the follwing code.
>Unfortunately it no longer works in access 2007. Is there some similar code
>that will work?
>
>Public Function FncCompactTheCurrentDB()
> CommandBars("Menu Bar"). _
> Controls("Tools"). _
> Controls("Database utilities"). _
> Controls("Compact and repair database..."). _
> accDoDefaultAction
>End Function
>
>Thank You,
>SL

 
Reply With Quote
 
SL
Guest
Posts: n/a
 
      29th Jan 2010
I know what you mean. I have some databases where I do periodically compact
them. But in this case, I prefer to do it once in code because I have many of
these back-end databases in different locations. The data is imported and
used as a reference. The data is not likely to change.

Thanks.

"Tom van Stiphout" wrote:

> On Thu, 28 Jan 2010 17:34:01 -0800, SL <(E-Mail Removed)>
> wrote:
>
> It's not recommended to compact yourself. Rather, split the database
> into front-end and back-end, store the back-end on the server, and
> schedule a task to compact it ever so often, for example using the
> /compact switch to msaccess.exe.
>
> -Tom.
> Microsoft Access MVP
>
>
> >Hello,
> >
> >I have recently upgrade to office 2007 from office 2003. To compact a
> >database from within the database itself, I used the follwing code.
> >Unfortunately it no longer works in access 2007. Is there some similar code
> >that will work?
> >
> >Public Function FncCompactTheCurrentDB()
> > CommandBars("Menu Bar"). _
> > Controls("Tools"). _
> > Controls("Database utilities"). _
> > Controls("Compact and repair database..."). _
> > accDoDefaultAction
> >End Function
> >
> >Thank You,
> >SL

> .
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      29th Jan 2010
But what you posted as working in Access 2003 only compacts the front-end,
not the back-end!

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"SL" <(E-Mail Removed)> wrote in message
news:FFE46594-C886-45CF-9F97-(E-Mail Removed)...
>I know what you mean. I have some databases where I do periodically compact
> them. But in this case, I prefer to do it once in code because I have many
> of
> these back-end databases in different locations. The data is imported and
> used as a reference. The data is not likely to change.
>
> Thanks.
>
> "Tom van Stiphout" wrote:
>
>> On Thu, 28 Jan 2010 17:34:01 -0800, SL <(E-Mail Removed)>
>> wrote:
>>
>> It's not recommended to compact yourself. Rather, split the database
>> into front-end and back-end, store the back-end on the server, and
>> schedule a task to compact it ever so often, for example using the
>> /compact switch to msaccess.exe.
>>
>> -Tom.
>> Microsoft Access MVP
>>
>>
>> >Hello,
>> >
>> >I have recently upgrade to office 2007 from office 2003. To compact a
>> >database from within the database itself, I used the follwing code.
>> >Unfortunately it no longer works in access 2007. Is there some similar
>> >code
>> >that will work?
>> >
>> >Public Function FncCompactTheCurrentDB()
>> > CommandBars("Menu Bar"). _
>> > Controls("Tools"). _
>> > Controls("Database utilities"). _
>> > Controls("Compact and repair database..."). _
>> > accDoDefaultAction
>> >End Function
>> >
>> >Thank You,
>> >SL

>> .
>>



 
Reply With Quote
 
SL
Guest
Posts: n/a
 
      2nd Feb 2010
Yes, but on first use of this back-end, I use it as a front-end. I import
data by running various macros, queries, VBA code all from one or more
buttons on a form. I will probably go back into it (as-required) to correct
or update the data. The last button runs this code which compacts the
database. It is very handy to have a button that will compact the database as
required rather than periodically.

SL

"Douglas J. Steele" wrote:

> But what you posted as working in Access 2003 only compacts the front-end,
> not the back-end!
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/DJSteele
> (no e-mails, please!)
>
> "SL" <(E-Mail Removed)> wrote in message
> news:FFE46594-C886-45CF-9F97-(E-Mail Removed)...
> >I know what you mean. I have some databases where I do periodically compact
> > them. But in this case, I prefer to do it once in code because I have many
> > of
> > these back-end databases in different locations. The data is imported and
> > used as a reference. The data is not likely to change.
> >
> > Thanks.
> >
> > "Tom van Stiphout" wrote:
> >
> >> On Thu, 28 Jan 2010 17:34:01 -0800, SL <(E-Mail Removed)>
> >> wrote:
> >>
> >> It's not recommended to compact yourself. Rather, split the database
> >> into front-end and back-end, store the back-end on the server, and
> >> schedule a task to compact it ever so often, for example using the
> >> /compact switch to msaccess.exe.
> >>
> >> -Tom.
> >> Microsoft Access MVP
> >>
> >>
> >> >Hello,
> >> >
> >> >I have recently upgrade to office 2007 from office 2003. To compact a
> >> >database from within the database itself, I used the follwing code.
> >> >Unfortunately it no longer works in access 2007. Is there some similar
> >> >code
> >> >that will work?
> >> >
> >> >Public Function FncCompactTheCurrentDB()
> >> > CommandBars("Menu Bar"). _
> >> > Controls("Tools"). _
> >> > Controls("Database utilities"). _
> >> > Controls("Compact and repair database..."). _
> >> > accDoDefaultAction
> >> >End Function
> >> >
> >> >Thank You,
> >> >SL
> >> .
> >>

>
>
> .
>

 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      2nd Feb 2010
Try it from the command line. See
http://www.codeforexcelandoutlook.co...cess-database/
for sample code (scroll down to the comments).

--JP

On Jan 28, 8:34*pm, SL <S...@discussions.microsoft.com> wrote:
> Hello,
>
> I have recently upgrade to office 2007 from office 2003. To compact a
> database from within the database itself, I used the follwing code.
> Unfortunately it no longer works in access 2007. Is there some similar code
> that will work?
>
> Public Function FncCompactTheCurrentDB()
> * *CommandBars("Menu Bar"). _
> * *Controls("Tools"). _
> * *Controls("Database utilities"). _
> * *Controls("Compact and repair database..."). _
> * *accDoDefaultAction
> End Function
>
> Thank You,
> SL

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2007 Compact Database Fix? Microsoft Microsoft Access 2 21st Aug 2009 12:56 AM
Access 2007 compact database Tony WONG Microsoft Access 1 21st Mar 2008 08:27 AM
Access 2007 - compact database Tony WONG Microsoft Access 2 20th Aug 2007 12:01 PM
How do I compact an Access database in 2007? =?Utf-8?B?Q3Jpcw==?= Microsoft Access 3 21st Mar 2007 05:44 AM
compact database Access 2007 via VB.net Adrian Microsoft Access 2 31st Jan 2007 01:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:03 AM.