<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>darragh murray &#187; Ms Access Tips</title>
	<atom:link href="http://www.darraghmurray.com/category/ms-access-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.darraghmurray.com</link>
	<description>Obeying the rules of thermodynamics since 1981!</description>
	<lastBuildDate>Wed, 10 Feb 2010 18:22:56 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Troubleshooting Potential Errors when Using Transactions in Ms Access &#8211; Do NOT Close the Workspace!</title>
		<link>http://www.darraghmurray.com/ms-access-tips/troubleshooting-potential-errors-when-using-transactions-in-ms-access-do-not-close-the-workspace/</link>
		<comments>http://www.darraghmurray.com/ms-access-tips/troubleshooting-potential-errors-when-using-transactions-in-ms-access-do-not-close-the-workspace/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 05:13:06 +0000</pubDate>
		<dc:creator>daz</dc:creator>
				<category><![CDATA[Ms Access Tips]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.darraghmurray.com/?p=192</guid>
		<description><![CDATA[I was doing some recordset juggling in vba and out of habit I usually close every object I open up explicit using the .close method on that object.
For example if I open up a database using something like this
Dim db as dao.database
Set db = currentDb
I will close it at the end of the function or [...]]]></description>
			<content:encoded><![CDATA[<p>I was doing some recordset juggling in vba and out of habit I usually close every object I open up explicit using the .close method on that object.</p>
<p>For example if I open up a database using something like this</p>
<p><code>Dim db as dao.database<br />
Set db = currentDb</code></p>
<p>I will close it at the end of the function or procedure</p>
<p><code>Db.close<br />
Set db = nothing</code></p>
<p>When using transactions, you make use of the workspace collection and you open it along the lines of</p>
<p><code>Dim myWrk as dao.workspace<br />
Set myWrk = DBEngine.Workspaces(0)</code></p>
<p>As usual, I want to close this at the end of the procedure along the lines of </p>
<p><code>myWrk.close<br />
set myWrk = nothing</code></p>
<p>This is were I went wrong</p>
<p>I was looping through a DAO recordset to check for conditions then make updates to a table. I wanted to make sure things didn’t screw up half way through so implemented some transactions, and then I started getting an error message</p>
<p><strong><code>Run-Time Error ‘3420’:<br />
Object Invalid or No Longer Set</code></strong></p>
<p>Specifically when I tried to use the .moveNext method of my recordset. </p>
<p>I began to tear my hair out! Google talks about updating my jet version, but that wasn’t the problem at all – I knew that I had the most up to date Jet engine.</p>
<p>It took me some time and a bit of research but I figured out it was happening when I made a call to another procedure while inside the recordset. Looking through the code, and nothing was wrong. I even pasted the code of the sub-procedure into my main procedure (minus all the variable setting and clean up objects stuff) and it work. Something was up in my sub procedures. </p>
<p>It was eventually a comment in <a href="http://allenbrowne.com/ser-37.html">this article on transactions at Allen Browne&#8217;s excellent Ms Access tips website</a> – <strong>I was explicitly closing the workspace. This is apparently a no-no. I deleted the .close line of code, and voila, it all worked!</strong></p>
<p class="fbconnect_share"><fb:share-button class="url" href="http://www.darraghmurray.com/ms-access-tips/troubleshooting-potential-errors-when-using-transactions-in-ms-access-do-not-close-the-workspace/" /></p><p align="left"><a class="tt" href="http://twitter.com/home/?status=Troubleshooting+Potential+Errors+when+Using+Transactions+in+Ms+Access+%E2%80%93+Do+NOT+Close+the+Workspace%21+http://iaz9f.th8.us" title="Post to Twitter"><img class="nothumb" src="http://www.darraghmurray.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Troubleshooting+Potential+Errors+when+Using+Transactions+in+Ms+Access+%E2%80%93+Do+NOT+Close+the+Workspace%21+http://iaz9f.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.darraghmurray.com/ms-access-tips/troubleshooting-potential-errors-when-using-transactions-in-ms-access-do-not-close-the-workspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
