<?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>brice cohey consulting</title>
	<atom:link href="http://bricecohey.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bricecohey.com</link>
	<description>Database Solutions for businesses of all sizes in managing, organizing and retrieving information</description>
	<lastBuildDate>Mon, 08 Aug 2011 14:13:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Clear multiple temp tables on Access close</title>
		<link>http://bricecohey.com/2011/07/clear-multiple-temp-tables-on-access-close/</link>
		<comments>http://bricecohey.com/2011/07/clear-multiple-temp-tables-on-access-close/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 21:44:42 +0000</pubDate>
		<dc:creator>briceadmin</dc:creator>
				<category><![CDATA[Access Functions]]></category>
		<category><![CDATA[clear tables]]></category>
		<category><![CDATA[shrink database]]></category>

		<guid isPermaLink="false">http://bricecohey.com/?p=123</guid>
		<description><![CDATA[This code is for illustration purposes only.  ALWAYS back up your database before you make changes. We all use temporary tables in Access but we don&#8217;t always remember to clear them.  You can write a query to clear each temp &#8230; <a href="http://bricecohey.com/2011/07/clear-multiple-temp-tables-on-access-close/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This code is for illustration purposes only.  <strong>ALWAYS</strong> back up your database <span style="text-decoration: underline;">before</span> you make changes.</p>
<p>We all use temporary tables in Access but we don&#8217;t always remember to clear them.  You can write a query to clear each temp table after you use it, but why create extra objects and increase the size of your database container?</p>
<p>Instead, use some code that will run as you shut down the database.  That way, your temporary tables will be empty before the database is compacted and repaired.  (Hopefully you have Compact on Close set to true in your Options.)</p>
<p>Make a local table called tblTempTableNames with one field:  TempTableName.  Enter the name of each temporary table into tblTempTableNames.  You can do this easily by right clicking the temporary table name, clicking Rename, using Control+C to copy, then right clicking an empty row in tblTempTableNames, and clicking Paste.</p>
<p>Now on your main menu (or whatever form has your Exit Access button) make a text box called txtTempTableName.  This text box does not have to be visible.  My form is called frmMainSwitchboard, so I will refer to my field as forms!frmMainSwitchboard!txtTempTableName.</p>
<p>Write the procedure:</p>
<p>Public Sub ClearAllTempTables</p>
<p>Dim rst as ADODB.Recordset</p>
<p>Dim mySQL as string</p>
<p>Set rst = New ADODB.Recordset</p>
<p>Set rst.ActiveConnection = CurrentProject.Connection</p>
<p>rst.CursorType = adOpenKeyset</p>
<p>rst.LockType=adLockOptimistic</p>
<p>rst.Source = “tblTempTableNames”</p>
<p>rst.Open options:=adCmdTable</p>
<p>Do While Not rst.EOF</p>
<p>&nbsp;</p>
<p>With rst</p>
<p>&nbsp;</p>
<p>Forms!frmMainSwitchboard!txtTempTableName=rst![TempTableName].Value</p>
<p>Msgbox rst![TempTableName].Value (Used for testing – can be remmed out.)</p>
<p>mySQL = “DELETE FROM “ &amp; forms!frmMainSwitchboard!txtTempTableName</p>
<p>DoCmd.RunSQL mySQL</p>
<p>&nbsp;</p>
<p>rst.MoveNext</p>
<p>&nbsp;</p>
<p>End With</p>
<p>Loop</p>
<p>rst.Close</p>
<p>Set rst=Nothing</p>
<p>&nbsp;</p>
<p>End Sub</p>
<p>Compile your code.</p>
<p>On your Exit Access button, add the following two lines of code before the Exit.Application line:</p>
<p>On Error Resume Next<br />
Call ClearAllTempTables</p>
<p>That&#8217;s it.  When you exit Access, your temporary tables will be cleared of records, but the table structures themselves remain intact.</p>
<p><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fbricecohey.com%2F2011%2F07%2Fclear-multiple-temp-tables-on-access-close%2F&amp;linkname=Clear%20multiple%20temp%20tables%20on%20Access%20close" title="Email" rel="nofollow" target="_blank"><img src="http://bricecohey.com/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fbricecohey.com%2F2011%2F07%2Fclear-multiple-temp-tables-on-access-close%2F&amp;linkname=Clear%20multiple%20temp%20tables%20on%20Access%20close" title="Facebook" rel="nofollow" target="_blank"><img src="http://bricecohey.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbricecohey.com%2F2011%2F07%2Fclear-multiple-temp-tables-on-access-close%2F&amp;title=Clear%20multiple%20temp%20tables%20on%20Access%20close" id="wpa2a_2">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://bricecohey.com/2011/07/clear-multiple-temp-tables-on-access-close/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Training for first 100 mile run</title>
		<link>http://bricecohey.com/2011/06/training-for-first-100-mile-run/</link>
		<comments>http://bricecohey.com/2011/06/training-for-first-100-mile-run/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 14:53:32 +0000</pubDate>
		<dc:creator>briceadmin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://bricecohey.com/?p=71</guid>
		<description><![CDATA[I am currently training for my first 100 mile run, the Lean Horse 100 in Hot Springs South Dakota.]]></description>
			<content:encoded><![CDATA[<div id="attachment_84" class="wp-caption alignleft" style="width: 160px"><a href="http://bricecohey.com/wp-content/uploads/2011/06/AnnOnHorse.jpg"><img class="size-thumbnail wp-image-84" title="AnnOnHorse" src="http://bricecohey.com/wp-content/uploads/2011/06/AnnOnHorse-150x150.jpg" alt="" width="150" height="150" /></a><p class="wp-caption-text">Taking a break</p></div>
<p>I am currently training for my first 100 mile run, the <a title="Lean Horse Hundred" href="http://www.leanhorsehundred.com/" target="_blank">Lean Horse 100 </a>in Hot Springs South Dakota.</p>
<p><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fbricecohey.com%2F2011%2F06%2Ftraining-for-first-100-mile-run%2F&amp;linkname=Training%20for%20first%20100%20mile%20run" title="Email" rel="nofollow" target="_blank"><img src="http://bricecohey.com/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fbricecohey.com%2F2011%2F06%2Ftraining-for-first-100-mile-run%2F&amp;linkname=Training%20for%20first%20100%20mile%20run" title="Facebook" rel="nofollow" target="_blank"><img src="http://bricecohey.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbricecohey.com%2F2011%2F06%2Ftraining-for-first-100-mile-run%2F&amp;title=Training%20for%20first%20100%20mile%20run" id="wpa2a_4">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://bricecohey.com/2011/06/training-for-first-100-mile-run/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combine Records Function for Access</title>
		<link>http://bricecohey.com/2011/06/combine-records-function-for-access/</link>
		<comments>http://bricecohey.com/2011/06/combine-records-function-for-access/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 14:47:37 +0000</pubDate>
		<dc:creator>briceadmin</dc:creator>
				<category><![CDATA[Access Functions]]></category>
		<category><![CDATA[recordset]]></category>

		<guid isPermaLink="false">http://bricecohey.com/?p=64</guid>
		<description><![CDATA[What if you want to attach a report to an email that goes to all of your customers?  You can write code to create the report and send it via the DoCmd.SendObject method.  That will create the report and attach &#8230; <a href="http://bricecohey.com/2011/06/combine-records-function-for-access/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>What if you want to attach a report to an email that goes to all of your customers?  You can write code to create the report and send it via the DoCmd.SendObject method.  That will create the report and attach it to an email.  But how do you get all the customers&#8217; emails into the BCC line?  (Always paste emails into the BCC or Blind Carbon Copy line, so you are not sharing email addresses.)</p>
<p>You can combine all the email addresses of your customers into one single string and pass that string to the email.  Here&#8217;s my example.  I have a table called Customers, and a field called EmailAddress.  Each customer has a CustomerID.</p>
<p>This example is for demonstration purposes only.</p>
<p>Function CombineEmails(strTblQryIn As String, strFieldNameIn As String, _</p>
<p>varPKValue As Variant, Optional strDelimiter) As Variant</p>
<p>&nbsp;</p>
<p>Set db = CurrentDb</p>
<p>Set qd = db.CreateQueryDef(&#8220;&#8221;)</p>
<p>&nbsp;</p>
<p>If IsMissing(strDelimiter) Then strDelimiter = &#8220;; &#8221;</p>
<p>strSQL = &#8220;SELECT [" &amp; strFieldNameIn &amp; "] FROM [" &amp; strTblQryIn &amp; "]&#8221;</p>
<p>&nbsp;</p>
<p>qd.SQL = strSQL</p>
<p>Set rs = qd.OpenRecordset</p>
<p>&nbsp;</p>
<p>Do Until rs.EOF</p>
<p>varResult = varResult &amp; rs.Fields(strFieldNameIn).Value &amp; strDelimiter</p>
<p>rs.MoveNext</p>
<p>Loop</p>
<p>&nbsp;</p>
<p>rs.Close</p>
<p>&nbsp;</p>
<p>If Len(varResult) &gt; 0 Then varResult = Left$(varResult, Len(varResult) &#8211; 1)</p>
<p>&nbsp;</p>
<p>CombineEmails = varResult</p>
<p>&nbsp;</p>
<p>Set rs = Nothing</p>
<p>Set qd = Nothing</p>
<p>Set db = Nothing</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>End Function</p>
<p>Then, I use a query (we&#8217;ll call it &#8220;qryCombineEmails&#8221;) that passes my table name and my field name to the function and I get my resultant string:</p>
<p>SELECT Customers.EmailAddress, Customers.CustomerID, CombineEmails(&#8220;Customers&#8221;,&#8221;EmailAddress&#8221;,[PeopleID],&#8221;;&#8221;) AS EmailList</p>
<p>FROM Customers</p>
<p>WHERE (((Customers.EmailAddress) Is Not Null));</p>
<p>The CombineEmails field in this query is the concatenated string.</p>
<p>Now I can pass that string to my DoCmd line like this:</p>
<p>DoCmd.SendObject acSendReport, &#8220;MonthlyReport&#8221;, acFormatRTF, , , DLookup(&#8220;EmailList&#8221;, &#8220;qryCombineEmails&#8221;), &#8220;Here&#8217;s our monthly report.&#8221;</p>
<p>The dlookup finds the EmailList in qryCombineEmails and pastes it into the BCC line of the email.  That way, I don&#8217;t have to type individual addresses into my email!</p>
<p><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fbricecohey.com%2F2011%2F06%2Fcombine-records-function-for-access%2F&amp;linkname=Combine%20Records%20Function%20for%20Access" title="Email" rel="nofollow" target="_blank"><img src="http://bricecohey.com/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fbricecohey.com%2F2011%2F06%2Fcombine-records-function-for-access%2F&amp;linkname=Combine%20Records%20Function%20for%20Access" title="Facebook" rel="nofollow" target="_blank"><img src="http://bricecohey.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbricecohey.com%2F2011%2F06%2Fcombine-records-function-for-access%2F&amp;title=Combine%20Records%20Function%20for%20Access" id="wpa2a_6">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://bricecohey.com/2011/06/combine-records-function-for-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

