PC Review


Reply
Thread Tools Rate Thread

Compact a back-end from a front end

 
 
=?Utf-8?B?U0hJUFA=?=
Guest
Posts: n/a
 
      7th May 2006
I have a front end and a back end. The back-end grows substantially through
some very complicated calculations. Can I compact the back-end through VB
code while I am still in the front end as long as there are not any other
users on the system? If so, does someone have the VB code to do so? I'm using
Access 2003.
--
M. Shipp
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      7th May 2006
You can use the CompactDatabase method of the DBEngine object.

Check whether or not the locking file (.ldb) exists: if it does, you can't
compact.

This is untested air-code that should work:

Dim strCurrentLDB As String
Dim strCurrentMDB As String
Dim strTempMDB As String

' strCurrentMDB is the full path to the database that needs to be
' compacted.
' strCurrentLDB is the full path to the locking file associated with
' the database that needs to be compacted
' You'll rename the database that needs to be compacted. The
' renamed file will be what's stored in strTempMDB

strCurrentMDB = "C:\MyFolder\MyData.MDB"
strCurrentLDB = "C:\MyFolder\MyData.LDB"
strTempMDB = "C:\MyFolder\MyData" & _
Format(Date(), "yyyymmdd") & ".bak"

' Check whether the locking file exists.

If Len(Dir(strCurrentLDB)) = 0 Then

' The locking file doesn't exist. Rename the database.
Name strCurrentMDB As strTempMDB

' Compact the renamed database to the "proper" database

DBEngine.CompactDatabase strTempMDB, strCurrentMDB

' It's up to you whether you want to keep the renamed copy.
' I do: it's my backup.

Else

' The locking file does exist: you can't back up

MsgBox "Cannot compact"

End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"SHIPP" <(E-Mail Removed)> wrote in message
news:B703240E-9255-4E49-AC98-(E-Mail Removed)...
>I have a front end and a back end. The back-end grows substantially through
> some very complicated calculations. Can I compact the back-end through VB
> code while I am still in the front end as long as there are not any other
> users on the system? If so, does someone have the VB code to do so? I'm
> using
> Access 2003.
> --
> M. Shipp



 
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
Front end won't compact. Need help refreshing bloated form. Sam Microsoft Access Forms 2 27th May 2009 10:38 PM
Compact Back End Ripper Microsoft Access Database Table Design 3 5th Mar 2008 10:54 PM
Compact and repair back end =?Utf-8?B?c2N1YmFkaXZlcg==?= Microsoft Access 15 25th Sep 2007 12:12 PM
Qury sub-forms breaks front-end to back-end when imprting from new front-end jphelan1242 via AccessMonster.com Microsoft Access Queries 0 17th May 2006 06:41 PM
Compact and repair Back End From Front End at Runtime bobdydd Microsoft Access 2 12th May 2006 06:03 PM


Features
 

Advertising
 

Newsgroups
 


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