Ok, forget about the once a month thing, but how can I compact with delphi (because other people are going to use the application and have a ms access database file on their computer.
Main Topics
Browse All TopicsI have this code that copies all data from a remote mysql database into a local ms access database.
This works like a charm, but......
Now what I want is to compact and repair the ms access database once a month and not everytime the application starts.
The thing is, I found a dosen of quistions on EE but my database is sort of implented in code (with extractfilepath and stuff), so it should not start with opening a opendialog to select the database (which many solutions do), the database should already be in the code and then compact and repair once a month (through timer or so).
Also a small favor I want to ask is the following: the copying of the data happends in splash form before the application really starts, now on this form I have some text which isn't visible when the form starts (the splash form), but when I get an error (like in the code below) the text appears, I want it to appear right when the form starts. Any idea on that?
So here are the codes I use: (connecting to ms access and a code to compact and repair)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Jet engine can do it, you need exclusive access to the file first, then you can reuse the code from
http://www.delphifaq.com/f
..........................
uses
ComObj;
// Compact and repair an access database, it requires exclusive db access.
// argument DB = Path to Access Database
function CompactAndRepair(DB: string) : boolean;
var
v: OLEvariant;
begin { CompactAndRepair }
Result := True;
try
v := CreateOLEObject('JRO.JetEn
try
v.CompactDatabase('Provide
'Provider=Microsoft.Jet.OL
'x;Jet OLEDB:Engine type=5');
DeleteFile(DB);
RenameFile(DB + 'x', DB)
finally
v := Unassigned
end; { try }
except
Result := False
end; { try }
end; { CompactAndRepair }
..........................
You can implement it in your code this way
AD_Access.Connected := False;
CompactAndRepair(sDatabase
AD_Access.Connected := True;
Regards,
B.
Business Accounts
Answer for Membership
by: thenelsonPosted on 2009-09-12 at 17:35:40ID: 25318525
Place this in windows scheduler and schedule for once per month: XE" "Your Database Path Name Here" /compact
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.E
change the path to MS Access as needed for your system.