NickHK said:
Under Option>General, check the Compact On Close.
As far I know it's a database specific and presumably could be changed by
anyone with Administer rights to the DB, maybe only if they have it open
exclusively.
Thanks for this. Now I have to think of a way to test whether the file
is in fact being compacted. Suggestions welcome.
Meanwhile, I'd like to press you on this: why do you think this is a
setting in the Jet database layer? Out of fairness, I'll tell you why
I think it isn't:
1) If the setting was in the database layer I would expect EITHER the
OLE DB provider OR the Jet and Replication Objects (JRO) to expose the
setting as a read/write property. I cannot find such a setting.
What I *can* find is that one may use the GetOption and SetOption
methods of the MS Access Application object to get/set the Compact On
Close option:
http://msdn.microsoft.com/library/d...wSettingOptionsFromVisualBasic_HV05188062.asp
Looking at the descriptions in the list, they all seem to refer to
settings in the MS Access UI that have no corresponding settings in the
Jet OLE DB provider.
2) I can write ADO code such as this:
Dim Con As Object
Dim i As Long
Set Con = CreateObject("ADODB.Connection")
With Con
.ConnectionString = MY_JET_CONN_STRING
For i = 1 to 100
.Open
.Execute "INSERT INTO MyTable VALUES (1);"
.Close
Next
End With
Assuming I am the only user of the database, I would be surprised if
there was a database level setting which would result in the file being
compacted each time I closed my connection.
When I compact my database using JRO it takes a relatively long time
and I end up with two files i.e. the original and the newly compacted
file. When I do the same using the tools in the MS Access UI I end up
with just one file but it takes a bit longer because it has to close
then reopen the original file, presumably because it gets overwritten
using the compacted copy.
I tried the above ADO code on a recently compacted mdb, first with
Compact On Close set off, then with it on. I could not detect any
significance difference in execution time to suggest the file was being
compacted 100 times in the process.
Jamie.
--