How to compact my BackEnd DB from inside FrontEnd DB

M

mota

Hi;
I want to compact my BackEnd Database (containing just tables),from the
FrontEnd program (Containing forms,modules,reports,queries) thru code.We
know some ways to compact the CurrentDB.But,is there any code to compact a
foreighn DB,executing from inside the current database?
Thank you in advance for your help
 
J

Jamie Richards

I think the command you require is the following:

CompactDatabase(SrcName As String, DstName As String, [DstLocale],
[Options], [SrcLocale])

The first argument is the db you want to compact. Use some code to pass the
path to that argument. I don't know which version of Access you're using,
but there is information on using this function in the Access 2000 Help.

I hope this is of some help.

Jamie
 
M

Mota

Dear jamie;
Im using Access XP (and 2003 too),and mentioned this as my first choice.But
it compacts DB and saves a new instance of it on another place,not on
itself.I used the same address(source path) as Destination,but an error
occured.How to adjust this for compacting a DB on itself?
Thank you for your help.

Jamie Richards said:
I think the command you require is the following:

CompactDatabase(SrcName As String, DstName As String, [DstLocale],
[Options], [SrcLocale])

The first argument is the db you want to compact. Use some code to pass
the path to that argument. I don't know which version of Access you're
using, but there is information on using this function in the Access 2000
Help.

I hope this is of some help.

Jamie

mota said:
Hi;
I want to compact my BackEnd Database (containing just tables),from the
FrontEnd program (Containing forms,modules,reports,queries) thru code.We
know some ways to compact the CurrentDB.But,is there any code to compact
a
foreighn DB,executing from inside the current database?
Thank you in advance for your help
 
D

Douglas J. Steele

I would recommend very strongly against compacting the database onto itself.

What I typically do is rename the existing backend, then compact the renamed
backend to the proper backend name.

That way, I have a backup copy. If you really don't want it, you can always
delete it once the compact is complete.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Mota said:
Dear jamie;
Im using Access XP (and 2003 too),and mentioned this as my first choice.But
it compacts DB and saves a new instance of it on another place,not on
itself.I used the same address(source path) as Destination,but an error
occured.How to adjust this for compacting a DB on itself?
Thank you for your help.

Jamie Richards said:
I think the command you require is the following:

CompactDatabase(SrcName As String, DstName As String, [DstLocale],
[Options], [SrcLocale])

The first argument is the db you want to compact. Use some code to pass
the path to that argument. I don't know which version of Access you're
using, but there is information on using this function in the Access 2000
Help.

I hope this is of some help.

Jamie

mota said:
Hi;
I want to compact my BackEnd Database (containing just tables),from the
FrontEnd program (Containing forms,modules,reports,queries) thru code.We
know some ways to compact the CurrentDB.But,is there any code to compact
a
foreighn DB,executing from inside the current database?
Thank you in advance for your help
 
J

Jamie Richards

As to often occurs I don't know where I got this, but it should do what Doug
recommends.

Function RepairMDB(YourDBSourceName As String) As Boolean
Dim ws As Workspace
Dim db As Database
Dim YourDbDestinationNnameAs String

YourDbDestinationNname= Left(YourDBSourceName, Len(YourDBSourceName) - 3)
& "NEW"
DBEngine.CompactDatabase YourDBSourceName, YourDbDestinationNname
Kill YourDBSourceName
Name YourDbDestinationNnameAs YourDBSourceName
RepairMDB = True

Exit_RepairMDB:
Exit Function

End Function

Fingers crossed!

Jamie

Douglas J. Steele said:
I would recommend very strongly against compacting the database onto
itself.

What I typically do is rename the existing backend, then compact the
renamed
backend to the proper backend name.

That way, I have a backup copy. If you really don't want it, you can
always
delete it once the compact is complete.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Mota said:
Dear jamie;
Im using Access XP (and 2003 too),and mentioned this as my first choice.But
it compacts DB and saves a new instance of it on another place,not on
itself.I used the same address(source path) as Destination,but an error
occured.How to adjust this for compacting a DB on itself?
Thank you for your help.

Jamie Richards said:
I think the command you require is the following:

CompactDatabase(SrcName As String, DstName As String, [DstLocale],
[Options], [SrcLocale])

The first argument is the db you want to compact. Use some code to
pass
the path to that argument. I don't know which version of Access you're
using, but there is information on using this function in the Access 2000
Help.

I hope this is of some help.

Jamie

Hi;
I want to compact my BackEnd Database (containing just tables),from
the
FrontEnd program (Containing forms,modules,reports,queries) thru code.We
know some ways to compact the CurrentDB.But,is there any code to compact
a
foreighn DB,executing from inside the current database?
Thank you in advance for your help
 
M

mota

Ok,Thank you.

Jamie Richards said:
As to often occurs I don't know where I got this, but it should do what Doug
recommends.

Function RepairMDB(YourDBSourceName As String) As Boolean
Dim ws As Workspace
Dim db As Database
Dim YourDbDestinationNnameAs String

YourDbDestinationNname= Left(YourDBSourceName, Len(YourDBSourceName) - 3)
& "NEW"
DBEngine.CompactDatabase YourDBSourceName, YourDbDestinationNname
Kill YourDBSourceName
Name YourDbDestinationNnameAs YourDBSourceName
RepairMDB = True

Exit_RepairMDB:
Exit Function

End Function

Fingers crossed!

Jamie

Douglas J. Steele said:
I would recommend very strongly against compacting the database onto
itself.

What I typically do is rename the existing backend, then compact the
renamed
backend to the proper backend name.

That way, I have a backup copy. If you really don't want it, you can
always
delete it once the compact is complete.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Mota said:
Dear jamie;
Im using Access XP (and 2003 too),and mentioned this as my first choice.But
it compacts DB and saves a new instance of it on another place,not on
itself.I used the same address(source path) as Destination,but an error
occured.How to adjust this for compacting a DB on itself?
Thank you for your help.

I think the command you require is the following:

CompactDatabase(SrcName As String, DstName As String, [DstLocale],
[Options], [SrcLocale])

The first argument is the db you want to compact. Use some code to
pass
the path to that argument. I don't know which version of Access you're
using, but there is information on using this function in the Access 2000
Help.

I hope this is of some help.

Jamie

Hi;
I want to compact my BackEnd Database (containing just tables),from
the
FrontEnd program (Containing forms,modules,reports,queries) thru code.We
know some ways to compact the CurrentDB.But,is there any code to compact
a
foreighn DB,executing from inside the current database?
Thank you in advance for your help
 
M

mota

Thats a good idea.Thank you.

Douglas J. Steele said:
I would recommend very strongly against compacting the database onto itself.

What I typically do is rename the existing backend, then compact the renamed
backend to the proper backend name.

That way, I have a backup copy. If you really don't want it, you can always
delete it once the compact is complete.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Mota said:
Dear jamie;
Im using Access XP (and 2003 too),and mentioned this as my first choice.But
it compacts DB and saves a new instance of it on another place,not on
itself.I used the same address(source path) as Destination,but an error
occured.How to adjust this for compacting a DB on itself?
Thank you for your help.

Jamie Richards said:
I think the command you require is the following:

CompactDatabase(SrcName As String, DstName As String, [DstLocale],
[Options], [SrcLocale])

The first argument is the db you want to compact. Use some code to pass
the path to that argument. I don't know which version of Access you're
using, but there is information on using this function in the Access 2000
Help.

I hope this is of some help.

Jamie

Hi;
I want to compact my BackEnd Database (containing just tables),from the
FrontEnd program (Containing forms,modules,reports,queries) thru code.We
know some ways to compact the CurrentDB.But,is there any code to compact
a
foreighn DB,executing from inside the current database?
Thank you in advance for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top