<?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>bobpeers -&#62; blog &#187; SQL</title>
	<atom:link href="http://blog.bobpeers.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bobpeers.com</link>
	<description>Better late than never</description>
	<lastBuildDate>Fri, 24 Jun 2011 12:34:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Unsafe Functions with JET Database Engine</title>
		<link>http://blog.bobpeers.com/2008/03/21/using-unsafe-functions-with-jet-database-engine/</link>
		<comments>http://blog.bobpeers.com/2008/03/21/using-unsafe-functions-with-jet-database-engine/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 13:39:19 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[JET]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/03/21/using-unsafe-functions-with-jet-database-engine/</guid>
		<description><![CDATA[I recently developed an HTA Application written in Javascript that used ADO to retrieve and update data in an MS Access database. One of the calls tried to open a stored query but failed with the error &#8216;Unkown function&#8217;. It turns out that the query contained the Nz VBA function to convert null values into [...]]]></description>
			<content:encoded><![CDATA[<p>I recently developed an <a href="http://msdn2.microsoft.com/en-us/library/ms536496(VS.85).aspx" title="MSDN HTA site">HTA Application</a> written in Javascript that used <a href="http://msdn2.microsoft.com/en-us/library/ms805098.aspx" title="MSDN ADO site">ADO</a> to retrieve and update data in an MS Access database.</p>
<p>One of the calls tried to open a stored query but failed with the error &#8216;Unkown function&#8217;. It turns out that the query contained the Nz VBA function to convert null values into some other, zero in my case.</p>
<p>This works fine when run from within MS Access but when called externally would fail due to the <a href="http://support.microsoft.com/kb/239482" title="Microsoft Help and Support">JET 4.0 database engines sandbox mode</a>.</p>
<p>I could have changed the registry key to allow the function but that would only work on my computer so as a fix I replaced all the references to Nz with IIf statements, not an elegant solution but it works none the less.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;count=none&amp;text=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;count=none&amp;text=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;linkname=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Fusing-unsafe-functions-with-jet-database-engine%2F&amp;title=Using%20Unsafe%20Functions%20with%20JET%20Database%20Engine" id="wpa2a_2"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/03/21/using-unsafe-functions-with-jet-database-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insert Random Numbers into MS Access Tables</title>
		<link>http://blog.bobpeers.com/2008/03/21/insert-random-numbers-into-ms-access-tables/</link>
		<comments>http://blog.bobpeers.com/2008/03/21/insert-random-numbers-into-ms-access-tables/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 13:18:34 +0000</pubDate>
		<dc:creator>Bob Peers</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.bobpeers.com/2008/03/21/insert-random-numbers-into-ms-access-tables/</guid>
		<description><![CDATA[Sometimes for testing it&#8217;s useful to be able to insert random numbers into a table field. This is an easy way to do this in MS Access. First write a custom function that looks like this. Function random(ID as Integer,min as Integer,max as Integer) As Integer random = Int((max - min + 1) * Rnd [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes for testing it&#8217;s useful to be able to insert random numbers into a table field. This is an easy way to do this in MS Access. First write a custom function that looks like this.</p>
<pre>Function random(ID as Integer,min as Integer,max as Integer) As Integer
random = Int((max - min + 1) * Rnd + min)
End Function</pre>
<p>The max and min are the lowest and highest random numbers you wish to generate, ID is a field from the table (it can be any field) you wish to insert the random number into.</p>
<p>Of course if your field is not an integer then you will have to change the ID as Integer part to ID as String for example.</p>
<p>The field is required so the function is called on every row, otherwise Access will just run the function once and then update every row with the same random number.<br />
To call the function from SQL use this.</p>
<pre>Update my_table set random_field=random(ID, 1, 10)</pre>
<p>In this case I&#8217;ve used an Update statement to insert a number between 1 and 10 into the field called random_field but it works equally for for Insert statements.</p>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;count=none&amp;text=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;counturl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;count=none&amp;text=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_evernote" href="http://www.addtoany.com/add_to/evernote?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="Evernote" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/evernote.png" width="16" height="16" alt="Evernote"/></a><a class="a2a_button_google_gmail" href="http://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="Google Gmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/gmail.png" width="16" height="16" alt="Google Gmail"/></a><a class="a2a_button_hotmail" href="http://www.addtoany.com/add_to/hotmail?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="Hotmail" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/live.png" width="16" height="16" alt="Hotmail"/></a><a class="a2a_button_wordpress" href="http://www.addtoany.com/add_to/wordpress?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="WordPress" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/wordpress.png" width="16" height="16" alt="WordPress"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="Facebook" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;linkname=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.bobpeers.com%2F2008%2F03%2F21%2Finsert-random-numbers-into-ms-access-tables%2F&amp;title=Insert%20Random%20Numbers%20into%20MS%20Access%20Tables" id="wpa2a_4"><img src="http://blog.bobpeers.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bobpeers.com/2008/03/21/insert-random-numbers-into-ms-access-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

