<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MS Access: Restarting and compacting the database programmatically</title>
	<atom:link href="http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/</link>
	<description>Just another programming weblog</description>
	<lastBuildDate>Thu, 04 Mar 2010 04:48:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: naphta</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-11726</link>
		<dc:creator>naphta</dc:creator>
		<pubDate>Wed, 07 Oct 2009 14:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-11726</guid>
		<description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;All tests are fines !&lt;/p&gt;

&lt;p&gt;I made test with an accdr connected by the network on a huge backend.&lt;/p&gt;

&lt;p&gt;No problemo
I give the code to a french forum.&lt;/p&gt;

&lt;p&gt;Bye&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hello,</p>

<p>All tests are fines !</p>

<p>I made test with an accdr connected by the network on a huge backend.</p>

<p>No problemo
I give the code to a french forum.</p>

<p>Bye</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Naphta</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-11725</link>
		<dc:creator>Naphta</dc:creator>
		<pubDate>Tue, 06 Oct 2009 21:52:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-11725</guid>
		<description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;It seems that it works as for self updating access frontend !&lt;/p&gt;

&lt;p&gt;the first tests are good !&lt;/p&gt;

&lt;p&gt;It&#039;s great !!&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hello,</p>

<p>It seems that it works as for self updating access frontend !</p>

<p>the first tests are good !</p>

<p>It&#8217;s great !!</p>

<p>Thanks</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-11649</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Fri, 11 Sep 2009 14:30:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-11649</guid>
		<description>&lt;p&gt;or alternatively, you might not want to compact at this moment:
&lt;code&gt;
bHandleCompactOnExit
Restarter.Restart Compact:=False
&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>or alternatively, you might not want to compact at this moment:
<pre><code>
bHandleCompactOnExit
Restarter.Restart Compact:=False
</code></pre></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-11648</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Fri, 11 Sep 2009 14:07:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-11648</guid>
		<description>&lt;p&gt;Here&#039;s a solution to make the excellent Restarter handle when Access is set to compact on exit.
Works fine in Access XP (2002).
No responsobilities taken.&lt;/p&gt;

&lt;p&gt;Best regards
Martin
&lt;code&gt;
&#039;Usage in conjunction with the Restarter:
&#039;Restarter.Restart Compact:=bHandleCompactOnExit()

&#039;And for the AutoExec macro or startup form:
&#039;RestoreAutoCompactSetting

&#039;You also need a table with the fields Parameter and Value _
    and a record where Parameter=&#039;CompactOnExit&#039;.
    
Public Function bHandleCompactOnExit() As Boolean
&#039;&#039;Compact on exit&#039; might need to be shut off, if so, save current setting _
    and shut off. Use code at application startup (i.e. the AutoExec macro _
    or starter form) to restore &#039;Compact on exit&#039;.
Dim iAutoCompact As Integer
    
    &#039;get setting
    iAutoCompact = AutoCompactSetting
    
    &#039;Store the value in a way that it is available at next startup.
    DoCmd.RunSQL &quot;UPDATE LocalSettings SET LocalSettings.[Value] = &#039;&quot; _
        &amp; iAutoCompact &amp; &quot;&#039; WHERE (((LocalSettings.Parameter)=&#039;CompactOnExit&#039;));&quot;
        
    If iAutoCompact = True Then _
        AutoCompactSetting = False
        
    bHandleCompactOnExit = iAutoCompact
    
End Function

Public Sub RestoreAutoCompactSetting()
&#039;Restore previous setting for &#039;Compact on exit&#039;. Call this sub from _
    AutoExec macro or your startup form.
    
    &#039;Get previously saved setting and set it for your application
    AutoCompactSetting = DLookup(&quot;Value&quot;, &quot;LocalSettings&quot;, _
        &quot;Parameter = &#039;CompactOnExit&#039;&quot;)
    
    &#039;Save a value for next startup that does not _
        affect &#039;compact on exit&#039;
    DoCmd.RunSQL &quot;UPDATE LocalSettings SET LocalSettings.[Value] = &#039;1&#039; &quot; _
        &amp; &quot;WHERE (((LocalSettings.Parameter)=&#039;CompactOnExit&#039;));&quot;

End Sub

Public Property Get AutoCompactSetting() As Integer
&#039;Get current setting for &#039;Compact on exit&#039;

    AutoCompactSetting = Application.GetOption(&quot;Auto Compact&quot;)
    
End Property

Public Property Let AutoCompactSetting(iOnOffVoid As Integer)
&#039;On/Off for &#039;CompactOnExit&#039; _
    iOnOffVoid decides: True (-1) &#039;CompactOnExit&#039; on _
                      False (0) &#039;CompactOnExit&#039; off _
                      else (e.g. &gt;0) no change
                      
    If (iOnOffVoid = True) Or (iOnOffVoid = False) Then _
        Application.SetOption &quot;Auto Compact&quot;, iOnOffVoid
        
End Property
&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a solution to make the excellent Restarter handle when Access is set to compact on exit.
Works fine in Access XP (2002).
No responsobilities taken.</p>

<p>Best regards
Martin
<pre><code>
'Usage in conjunction with the Restarter:
'Restarter.Restart Compact:=bHandleCompactOnExit()

'And for the AutoExec macro or startup form:
'RestoreAutoCompactSetting

'You also need a table with the fields Parameter and Value _
    and a record where Parameter='CompactOnExit'.
    
Public Function bHandleCompactOnExit() As Boolean
''Compact on exit' might need to be shut off, if so, save current setting _
    and shut off. Use code at application startup (i.e. the AutoExec macro _
    or starter form) to restore 'Compact on exit'.
Dim iAutoCompact As Integer
    
    'get setting
    iAutoCompact = AutoCompactSetting
    
    'Store the value in a way that it is available at next startup.
    DoCmd.RunSQL "UPDATE LocalSettings SET LocalSettings.[Value] = '" _
        &amp; iAutoCompact &amp; "' WHERE (((LocalSettings.Parameter)='CompactOnExit'));"
        
    If iAutoCompact = True Then _
        AutoCompactSetting = False
        
    bHandleCompactOnExit = iAutoCompact
    
End Function

Public Sub RestoreAutoCompactSetting()
'Restore previous setting for 'Compact on exit'. Call this sub from _
    AutoExec macro or your startup form.
    
    'Get previously saved setting and set it for your application
    AutoCompactSetting = DLookup("Value", "LocalSettings", _
        "Parameter = 'CompactOnExit'")
    
    'Save a value for next startup that does not _
        affect 'compact on exit'
    DoCmd.RunSQL "UPDATE LocalSettings SET LocalSettings.[Value] = '1' " _
        &amp; "WHERE (((LocalSettings.Parameter)='CompactOnExit'));"

End Sub

Public Property Get AutoCompactSetting() As Integer
'Get current setting for 'Compact on exit'

    AutoCompactSetting = Application.GetOption("Auto Compact")
    
End Property

Public Property Let AutoCompactSetting(iOnOffVoid As Integer)
'On/Off for 'CompactOnExit' _
    iOnOffVoid decides: True (-1) 'CompactOnExit' on _
                      False (0) 'CompactOnExit' off _
                      else (e.g. &gt;0) no change
                      
    If (iOnOffVoid = True) Or (iOnOffVoid = False) Then _
        Application.SetOption "Auto Compact", iOnOffVoid
        
End Property
</code></pre></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Renaud</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-10394</link>
		<dc:creator>Renaud</dc:creator>
		<pubDate>Tue, 21 Apr 2009 02:08:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-10394</guid>
		<description>&lt;p&gt;@Andrew,&lt;br /&gt;
could you send me your test database (see email at the bottom of the page).&lt;br /&gt;
Also, the code should only be used for a local database that is currently opened only once, not a shared one that could be opened by multiple users.&lt;/p&gt;

&lt;p&gt;Thinks you can try:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;make sure you have the PING command. It should be there, but open a command prompt and check that it&#039;s installed.&lt;/li&gt;
&lt;li&gt;Try to change the wait duration for the PING command in the VBA code for Restart():&lt;br /&gt;
Change the line that contains:&lt;br /&gt;
&lt;code&gt;ping 0.0.0.255 -n 1 __-w 100__ &gt; nul&lt;/code&gt;
to&lt;br /&gt;
&lt;code&gt;ping 0.0.0.255 -n 1 __-w 1500__ &gt; nul&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
		<content:encoded><![CDATA[<p>@Andrew,<br />
could you send me your test database (see email at the bottom of the page).<br />
Also, the code should only be used for a local database that is currently opened only once, not a shared one that could be opened by multiple users.</p>

<p>Thinks you can try:</p>

<ul>
<li>make sure you have the PING command. It should be there, but open a command prompt and check that it&#8217;s installed.</li>
<li>Try to change the wait duration for the PING command in the VBA code for Restart():<br />
Change the line that contains:<br />
<code>ping 0.0.0.255 -n 1 __-w 100__ &amp;gt; nul</code>
to<br />
<code>ping 0.0.0.255 -n 1 __-w 1500__ &amp;gt; nul</code></li>
</ul>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-10383</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 17 Apr 2009 14:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-10383</guid>
		<description>&lt;p&gt;Hi I am running your code in Access 2003 but in Access 2000 file format&lt;/p&gt;

&lt;p&gt;I get the following error:&lt;/p&gt;

&lt;p&gt;&quot;Could not use &#039;Z:&#92;Project Metrics&#92;Project Metrics -test.mdb&#039;; file already in use&quot;&lt;/p&gt;

&lt;p&gt;I assume this is because it tries to open the database too quickly is this the case and if so can be further slowed down?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi I am running your code in Access 2003 but in Access 2000 file format</p>

<p>I get the following error:</p>

<p>&#8220;Could not use &#8216;Z:&#92;Project Metrics&#92;Project Metrics -test.mdb&#8217;; file already in use&#8221;</p>

<p>I assume this is because it tries to open the database too quickly is this the case and if so can be further slowed down?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Renaud</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-10005</link>
		<dc:creator>Renaud</dc:creator>
		<pubDate>Fri, 13 Feb 2009 04:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-10005</guid>
		<description>&lt;p&gt;About Compacting: now the code offers you the option to compact the database during restart.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>About Compacting: now the code offers you the option to compact the database during restart.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: bil643</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-9319</link>
		<dc:creator>bil643</dc:creator>
		<pubDate>Mon, 13 Oct 2008 15:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-9319</guid>
		<description>&lt;p&gt;We don&#039;t save data after inserting it in MS Access table. However when we open the table we observe that data is not vanished? Why?&lt;/p&gt;

&lt;p&gt;Dear can u help me to solve this question? I hope to listen from you soon.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>We don&#8217;t save data after inserting it in MS Access table. However when we open the table we observe that data is not vanished? Why?</p>

<p>Dear can u help me to solve this question? I hope to listen from you soon.</p>

<p>Thanks</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jacques</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-9100</link>
		<dc:creator>Jacques</dc:creator>
		<pubDate>Fri, 05 Sep 2008 09:03:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-9100</guid>
		<description>&lt;p&gt;@ Lu&lt;/p&gt;

&lt;p&gt;It&#039;s is not recommended to use &#039;Auto Compact&#039; in shared environments&#92;over networks etc. - see this thread (which basically confirms my own findings): http://www.utteraccess.com/forums/showflat.php?Cat=&amp;Number=603048&amp;Main=601621&lt;/p&gt;

&lt;p&gt;Compacting is a delicate process, which should be executed with &#039;care&#039; - only in a stable environment (local), making a backup first etc. (ok, I don&#039;t always do that myself either, but we all should...).&lt;/p&gt;

&lt;p&gt;So, compacting from code (http://www.mvps.org/access/general/gen0041.htm), you know when it is finished as it returns the result
(http://msdn.microsoft.com/en-us/library/ms696119.aspx) - after that you could use Renaud&#039;s batch file to restart.&lt;/p&gt;

&lt;p&gt;This thread contains some code to compact when your MDB reaches a certain size:
http://www.tek-tips.com/viewthread.cfm?qid=642227&lt;/p&gt;

&lt;p&gt;And here some sleeker code tha gives the user 3 options: http://forums.devarticles.com/microsoft-access-development-49/compact-database-via-vba-24958.html&lt;/p&gt;

&lt;p&gt;I haven&#039;t tested all the code, so don&#039;t shoot the messenger...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@ Lu</p>

<p>It&#8217;s is not recommended to use &#8216;Auto Compact&#8217; in shared environments&#92;over networks etc. -- see this thread (which basically confirms my own findings): <a href="http://www.utteraccess.com/forums/showflat.php?Cat=&amp;Number=603048&amp;Main=601621" rel="nofollow">http://www.utteraccess.com/forums/showflat.php?Cat=&amp;Number=603048&amp;Main=601621</a></p>

<p>Compacting is a delicate process, which should be executed with &#8216;care&#8217; -- only in a stable environment (local), making a backup first etc. (ok, I don&#8217;t always do that myself either, but we all should&#8230;).</p>

<p>So, compacting from code (<a href="http://www.mvps.org/access/general/gen0041.htm" rel="nofollow">http://www.mvps.org/access/general/gen0041.htm</a>), you know when it is finished as it returns the result
(<a href="http://msdn.microsoft.com/en-us/library/ms696119.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms696119.aspx</a>) -- after that you could use Renaud&#8217;s batch file to restart.</p>

<p>This thread contains some code to compact when your MDB reaches a certain size:
<a href="http://www.tek-tips.com/viewthread.cfm?qid=642227" rel="nofollow">http://www.tek-tips.com/viewthread.cfm?qid=642227</a></p>

<p>And here some sleeker code tha gives the user 3 options: <a href="http://forums.devarticles.com/microsoft-access-development-49/compact-database-via-vba-24958.html" rel="nofollow">http://forums.devarticles.com/microsoft-access-development-49/compact-database-via-vba-24958.html</a></p>

<p>I haven&#8217;t tested all the code, so don&#8217;t shoot the messenger&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Lu Anne</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8987</link>
		<dc:creator>Lu Anne</dc:creator>
		<pubDate>Wed, 13 Aug 2008 14:25:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8987</guid>
		<description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;  Dim compactonclose As Variant
    compactonclose = Application.GetOption(&quot;Auto Compact&quot;)
    If compactonclose Then
        MsgBox &quot;I am set to compact on close&quot;
  End If
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;The above routine will detect if compact on close is selected. As for detecting when the database has actually closed, still working on that. I&#039;ll keep you posted.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p><pre><pre><code>  Dim compactonclose As Variant
    compactonclose = Application.GetOption("Auto Compact")
    If compactonclose Then
        MsgBox "I am set to compact on close"
  End If
</code></pre></pre></p>

<p>The above routine will detect if compact on close is selected. As for detecting when the database has actually closed, still working on that. I&#8217;ll keep you posted.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Renaud</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8984</link>
		<dc:creator>Renaud</dc:creator>
		<pubDate>Wed, 13 Aug 2008 01:39:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8984</guid>
		<description>&lt;p&gt;@Lu: it&#039;s a good point. When access compacts on close it will take over its own restarting process and remove the database lock file.&lt;br /&gt;
In that case the batch file will assume that the database is closed and try to re-open it, which Access will not do since it is currently compacting.&lt;/p&gt;

&lt;p&gt;I&#039;ll see what can be done. My guess would be to try to detect whether the database is set to compact on close and find a way to detect when access has completed the compacting process.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Lu: it&#8217;s a good point. When access compacts on close it will take over its own restarting process and remove the database lock file.<br />
In that case the batch file will assume that the database is closed and try to re-open it, which Access will not do since it is currently compacting.</p>

<p>I&#8217;ll see what can be done. My guess would be to try to detect whether the database is set to compact on close and find a way to detect when access has completed the compacting process.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Lu Anne</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8983</link>
		<dc:creator>Lu Anne</dc:creator>
		<pubDate>Tue, 12 Aug 2008 16:14:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8983</guid>
		<description>&lt;p&gt;I am trying your restart function in Access 2003 - if I don&#039;t set the database to compact on close, the function works fiune. When I set the database to compact on close it never reopens the data abse. any suggestions?&lt;/p&gt;

&lt;p&gt;Thanks, Lu&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I am trying your restart function in Access 2003 -- if I don&#8217;t set the database to compact on close, the function works fiune. When I set the database to compact on close it never reopens the data abse. any suggestions?</p>

<p>Thanks, Lu</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Renaud</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8973</link>
		<dc:creator>Renaud</dc:creator>
		<pubDate>Sat, 09 Aug 2008 05:29:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8973</guid>
		<description>&lt;p&gt;@Jacques: you make some valid points and I have updated the article, the code and test database to reflect these improvements and corrections.&lt;br /&gt;
Thanks for the comments.&lt;/p&gt;

&lt;p&gt;The test database for restarting the application is now available in Access2007 and Access2000 versions.&lt;br /&gt;
If someone could test the MDB version and let me know if it works properly or not I&#039;d be grateful.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Jacques: you make some valid points and I have updated the article, the code and test database to reflect these improvements and corrections.<br />
Thanks for the comments.</p>

<p>The test database for restarting the application is now available in Access2007 and Access2000 versions.<br />
If someone could test the MDB version and let me know if it works properly or not I&#8217;d be grateful.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jacques</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8970</link>
		<dc:creator>Jacques</dc:creator>
		<pubDate>Fri, 08 Aug 2008 12:53:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8970</guid>
		<description>&lt;p&gt;Nice, simple and clean.&lt;/p&gt;

&lt;p&gt;A few comments:&lt;/p&gt;

&lt;p&gt;1) I realise you work with Access 2007 (with new extensions) - all previous versions use .mdb for the DB itself and .ldb for the lockfile - by adding the &#039;l&#039; in line 3, it doesn&#039;t work for older versions (it should replace the &#039;m&#039;) - any idea how to make it generic?&lt;/p&gt;

&lt;p&gt;1a) Say you run a DB in execute-modus (extension = .accde) - then looking for the &#039;l&#039;+&#039;accde&#039;-file is not going to work, as the lockfile will still be &#039;.laccdb&#039; - right?&lt;/p&gt;

&lt;p&gt;2) When Access crashes, it doesn&#039;t delete the lockfile - in case you run this batchfile and the .ldb not being removed, you end up in an infinite loop - not a resource-hog, I assume, but on creating this batchfile again (on restarting Access), you might run into trouble, as the previous batchfile is still present and you can&#039;t create a new batchfile with the same name. 
Perhaps you should build in some timer that self-deletes the batch file (after 2 minutes). And give batchfiles an unique name (e.g. incl. a timestamp).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Nice, simple and clean.</p>

<p>A few comments:</p>

<p>1) I realise you work with Access 2007 (with new extensions) -- all previous versions use .mdb for the DB itself and .ldb for the lockfile -- by adding the &#8216;l&#8217; in line 3, it doesn&#8217;t work for older versions (it should replace the &#8216;m&#8217;) -- any idea how to make it generic?</p>

<p>1a) Say you run a DB in execute-modus (extension = .accde) -- then looking for the &#8216;l&#8217;+'accde&#8217;-file is not going to work, as the lockfile will still be &#8216;.laccdb&#8217; -- right?</p>

<p>2) When Access crashes, it doesn&#8217;t delete the lockfile -- in case you run this batchfile and the .ldb not being removed, you end up in an infinite loop -- not a resource-hog, I assume, but on creating this batchfile again (on restarting Access), you might run into trouble, as the previous batchfile is still present and you can&#8217;t create a new batchfile with the same name. 
Perhaps you should build in some timer that self-deletes the batch file (after 2 minutes). And give batchfiles an unique name (e.g. incl. a timestamp).</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Renaud</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8961</link>
		<dc:creator>Renaud</dc:creator>
		<pubDate>Wed, 06 Aug 2008 02:38:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8961</guid>
		<description>&lt;p&gt;Hi Tony,&lt;br /&gt;
thanks for your message.&lt;/p&gt;

&lt;p&gt;Regarding the lock file, I assume that its deletion by Access is the last action performed once a database is closed, which would make sense since it&#039;s the whole purpose of a lock file.&lt;br /&gt;
I do not attempt to delete the lock file, Access does that; the last sentence of the batch file, the &lt;code&gt;DEL %0&lt;/code&gt; actually deletes the batch file itself to keep things clean.&lt;/p&gt;

&lt;p&gt;Thank you again for dropping by.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Tony,<br />
thanks for your message.</p>

<p>Regarding the lock file, I assume that its deletion by Access is the last action performed once a database is closed, which would make sense since it&#8217;s the whole purpose of a lock file.<br />
I do not attempt to delete the lock file, Access does that; the last sentence of the batch file, the <code>DEL %0</code> actually deletes the batch file itself to keep things clean.</p>

<p>Thank you again for dropping by.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tony D'Ambra</title>
		<link>http://blog.nkadesign.com/2008/ms-access-restarting-the-database-programmatically/comment-page-1/#comment-8960</link>
		<dc:creator>Tony D'Ambra</dc:creator>
		<pubDate>Wed, 06 Aug 2008 01:13:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nkadesign.com/?p=73#comment-8960</guid>
		<description>&lt;p&gt;Compliments on your  very elegant blog and code.&lt;/p&gt;

&lt;p&gt;A couple of months back I tackled the issue of forcing a restart by calling a VB6 EXE on an Access UNLOAD event and passing the database file path as a command-line parameter.  Now I can see your self-contained BAT file approach is better.  I used WAIT to delay the restart, and then trapped the Unable to Unlock File error in a resume loop until Access unlocked the MDB file and deleted the LDB file. I was wondering why in your code, you try deleting the LDB file outside Access?  Is there not a risk of corruption as the previous instance of Access would still exist until after its deletion of the LDB file?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Compliments on your  very elegant blog and code.</p>

<p>A couple of months back I tackled the issue of forcing a restart by calling a VB6 EXE on an Access UNLOAD event and passing the database file path as a command-line parameter.  Now I can see your self-contained BAT file approach is better.  I used WAIT to delay the restart, and then trapped the Unable to Unlock File error in a resume loop until Access unlocked the MDB file and deleted the LDB file. I was wondering why in your code, you try deleting the LDB file outside Access?  Is there not a risk of corruption as the previous instance of Access would still exist until after its deletion of the LDB file?</p>]]></content:encoded>
	</item>
</channel>
</rss>
