|
Home > Archive > MS Access Multiuser > September 2005 > How to compress a backend?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to compress a backend?
|
|
| HenroV@gmail.com 2005-09-26, 3:24 am |
| I have a split database.
In the frontend I have some code that will (on request of the user, not
every time) compress the frontend on exit.
But is there any code that will allow me to compress the BACKEND on
demand? Taking in account that multiple users might be logged in at the
same time?
TIA,
Henro
| |
| Alex Dybenko 2005-09-26, 7:24 am |
| Hi,
you should first get a list of users who logged on:
http://www.mvps.org/access/general/gen0034.htm
then show them a message to log off
wait some time and force logoff (youi can use a special table in BE to set
time of force logoff)
then you can compact BE
--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
<HenroV@gmail.com> wrote in message
news:1127722892.790819.280330@g44g2000cwa.googlegroups.com...
>I have a split database.
> In the frontend I have some code that will (on request of the user, not
> every time) compress the frontend on exit.
> But is there any code that will allow me to compress the BACKEND on
> demand? Taking in account that multiple users might be logged in at the
> same time?
>
> TIA,
>
> Henro
>
| |
| Henrootje 2005-09-26, 7:24 am |
| Thank you.
It is especially the last part I am interested in: how can I compact
the Backend without having to 'go there'? I would like to give an user
a button to compact the backend
| |
| Douglas J. Steele 2005-09-26, 7:24 am |
| If there aren't any connections currently open to the backend, you can use
the DAO CompactDatabase method in code to compact it.
What I typically do is rename the backend from MyBackend.mdb to
MyBackendyyyymmdd.bak (where yyyymmdd is the current date), and then use
CompactDatabase to compact that backup version to the correct name.
Function CompactDatabase(Data
baseName As String) As Boolean
' Renames the existing backend database from .MDB to .BAK
' Compacts the backup copy to the "proper" database
'
' Returns True if successful, False otherwise
On Error GoTo Err_CompactDatabase
Dim booStatus As Boolean
Dim strBackupFile As String
booStatus = True
' Make sure that DatabaseName exists
If Len(Dir$(DatabaseNam
e)) > 0 Then
' Figure out what the backup file should be named
If StrComp(Right$(Datab
aseName, 4), ".mdb", vbTextCompare) = 0 Then
strBackupFile = Left$(DatabaseName, Len(DatabaseName) - 4) &
".bak"
' Determine whether the backup file already exists,
' and delete it if it does.
If Len(Dir$(strBackupFi
le)) > 0 Then
Kill strBackupFile
End If
Name DatabaseName As strBackupFile
' Do the actual compact
DBEngine.CompactDatabase strBackupFile, DatabaseName
End If
End If
End_CompactDatabase:
CompactDatabase = booStatus
Exit Function
Err_CompactDatabase:
booStatus = False
Msgbox Err.Number & ": " & Err.Description
Resume End_CompactDatabase
End Function
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Henrootje" <HenroV@gmail.com> wrote in message
news:1127726941.883481.261040@g47g2000cwa.googlegroups.com...
> Thank you.
>
> It is especially the last part I am interested in: how can I compact
> the Backend without having to 'go there'? I would like to give an user
> a button to compact the backend
>
| |
| Henrootje 2005-09-26, 7:24 am |
| That is exactly what I needed, thank you Doug!
|
|
|
|
|