<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Microsoft Access Team Blog : Code</title><link>http://blogs.msdn.com/access/archive/tags/Code/default.aspx</link><description>Tags: Code</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Running a Command as Administrator in VBA</title><link>http://blogs.msdn.com/access/archive/2009/11/11/running-a-command-as-administrator-in-vba.aspx</link><pubDate>Wed, 11 Nov 2009 16:23:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9920880</guid><dc:creator>robcooper</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/access/comments/9920880.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9920880</wfw:commentRss><description>&lt;p&gt;We received a question the other day from someone who was using the Shell function in VBA to run a command in a command prompt. The command in question was &lt;a href="http://technet.microsoft.com/en-us/library/cc787375(WS.10).aspx"&gt;netsh dhcp&lt;/a&gt;, but this could apply to any number of commands.&lt;/p&gt;  &lt;p&gt;The original code was as follows:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;Shell &amp;quot;c:\windows\system32\cmd.exe /k netsh –c dhcp&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This code had worked for a while, but on Windows Server 2008 (and presumably Windows Vista and Windows 7), this command requires elevated permissions. There are likely a few ways to do this, but we’ll look at the runas command to make this work.&lt;/p&gt;  &lt;p&gt;The &lt;a href="http://technet.microsoft.com/en-us/library/bb490994.aspx"&gt;runas&lt;/a&gt; command allows you to start a process as another user. For our purposes, the syntax is something like:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;RUNAS /user:&amp;lt;UserName&amp;gt; program&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To run netsh using the runas command, you could change the code as follows:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;Shell &amp;quot;runas /user:administrator &amp;quot;&amp;quot;c:\windows\system32\cmd.exe /k netsh –c dhcp&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This will launch a command window and prompt you for the administrator password in the command window itself.&lt;/p&gt;  &lt;p&gt;Another way to do this is to use &amp;quot;runas&amp;quot; as the verb for the &lt;a href="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx"&gt;ShellExecute&lt;/a&gt; API function as follows:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;Private Declare Function ShellExecute Lib &amp;quot;shell32.dll&amp;quot; Alias &amp;quot;ShellExecuteA&amp;quot; _      &lt;br /&gt;&amp;#160; (ByVal hWnd As Long, _       &lt;br /&gt;&amp;#160;&amp;#160; ByVal lpOperation As String, _       &lt;br /&gt;&amp;#160;&amp;#160; ByVal lpFile As String, _       &lt;br /&gt;&amp;#160;&amp;#160; ByVal lpParameters As String, _       &lt;br /&gt;&amp;#160;&amp;#160; ByVal lpDirectory As String, _       &lt;br /&gt;&amp;#160;&amp;#160; ByVal nShowCmd As Long) As Long&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;Sub RunAsAdmin()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Const SW_NORMAL As Long = 1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ShellExecute hWndAccessApp(), _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;runas&amp;quot;, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;c:\windows\system32\cmd.exe&amp;quot;, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;/k netsh -c dhcp&amp;quot;, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;c:\windows\system32&amp;quot;, SW_NORMAL       &lt;br /&gt;End Sub&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;When you run the RunAsAdmin procedure, you should be prompted by Windows to run the specified command.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9920880" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category></item><item><title>A better way to reference tab control pages</title><link>http://blogs.msdn.com/access/archive/2009/11/05/a-better-way-to-reference-tab-control-pages.aspx</link><pubDate>Fri, 06 Nov 2009 02:38:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918357</guid><dc:creator>cdowns</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/access/comments/9918357.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9918357</wfw:commentRss><description>&lt;p&gt;In VBA, a common way to refer to the pages of a tab control is to use the &lt;strong&gt;Value&lt;/strong&gt; property. However, Luke Chung, President of FMS Inc., recommends using the &lt;strong&gt;PageIndex&lt;/strong&gt; property instead. &lt;a href="http://www.fmsinc.com/microsoftaccess/forms/tabs"&gt;Click here&lt;/a&gt; to find out why! &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/Abetterwaytoreferencetabcontrolpages_1063A/tabs_4.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="tabs" border="0" alt="tabs" src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/Abetterwaytoreferencetabcontrolpages_1063A/tabs_thumb_1.jpg" width="504" height="275" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h6&gt;Send your Power Tips to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;.&lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918357" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/User+Interface/default.aspx">User Interface</category><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Convert hexadecimal color codes so you can use them in code</title><link>http://blogs.msdn.com/access/archive/2009/10/26/convert-hexadecimal-color-codes-so-you-can-use-them-in-code.aspx</link><pubDate>Mon, 26 Oct 2009 15:14:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9912963</guid><dc:creator>cdowns</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/access/comments/9912963.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9912963</wfw:commentRss><description>&lt;h5&gt;Today's guest blogger is Michael Merlin, Lead Software Developer at &lt;a href="http://ecoms.com" target="_blank"&gt;Electronic Communities&lt;/a&gt;. &lt;/h5&gt;  &lt;p&gt;I recently wasted an hour trying to set a field's Back Color property to the hex code generated by the color picker. I figured it out after some searching, but still nobody online had the exact correct answer. I wrote a function that lets you easily use the hex color in code. The secret is to swap the R and the B, and then convert the hex to long. Further explanation follows in the comments of the function.&lt;/p&gt;  &lt;p&gt;Cheers!    &lt;br /&gt;Michael&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; HexColor(strHex &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;

    &lt;span class="rem"&gt;'converts Hex string to long number, for colors&lt;/span&gt;
    &lt;span class="rem"&gt;'the leading # is optional&lt;/span&gt;

    &lt;span class="rem"&gt;'example usage&lt;/span&gt;
    &lt;span class="rem"&gt;'Me.iSupplier.BackColor = HexColor(&amp;quot;FCA951&amp;quot;)&lt;/span&gt;
    &lt;span class="rem"&gt;'Me.iSupplier.BackColor = HexColor(&amp;quot;#FCA951&amp;quot;)&lt;/span&gt;

    &lt;span class="rem"&gt;'the reason for this function is to programmatically use the&lt;/span&gt;
    &lt;span class="rem"&gt;'Hex colors generated by the color picker.&lt;/span&gt;
    &lt;span class="rem"&gt;'The trick is, you need to reverse the first and last hex of the&lt;/span&gt;
    &lt;span class="rem"&gt;'R G B combination and convert to Long&lt;/span&gt;
    &lt;span class="rem"&gt;'so that if the color picker gives you this color #FCA951&lt;/span&gt;
    &lt;span class="rem"&gt;'to set this in code, we need to return CLng(&amp;amp;H51A9FC)&lt;/span&gt;
    
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strColor &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strR &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strG &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strB &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;
    
    &lt;span class="rem"&gt;'strip the leading # if it exists&lt;/span&gt;
    &lt;span class="kwrd"&gt;If&lt;/span&gt; Left(strHex, 1) = &lt;span class="str"&gt;&amp;quot;#&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
        strHex = Right(strHex, Len(strHex) - 1)
    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
    
    &lt;span class="rem"&gt;'reverse the first two and last two hex numbers of the R G B values&lt;/span&gt;
    strR = Left(strHex, 2)
    strG = Mid(strHex, 3, 2)
    strB = Right(strHex, 2)
    strColor = strB &amp;amp; strG &amp;amp; strR
    HexColor = &lt;span class="kwrd"&gt;CLng&lt;/span&gt;(&lt;span class="str"&gt;&amp;quot;&amp;amp;H&amp;quot;&lt;/span&gt; &amp;amp; strColor)

&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912963" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Report/default.aspx">Report</category><category domain="http://blogs.msdn.com/access/archive/tags/User+Interface/default.aspx">User Interface</category><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Expand only the subdatasheets you want</title><link>http://blogs.msdn.com/access/archive/2009/10/21/expand-only-the-subdatasheets-you-want.aspx</link><pubDate>Wed, 21 Oct 2009 15:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9910662</guid><dc:creator>cdowns</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/access/comments/9910662.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9910662</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today's guest blogger is Pavlo Pedan of ARGO Business Corp. He has 15 years of experience with Access and has a great site of tips&amp;#160; at &lt;/strong&gt;&lt;a href="http://sites.google.com/site/msaccesscode/"&gt;&lt;strong&gt;http://sites.google.com/site/msaccesscode/&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you have a form that contains subdatasheets, you can use the following VBA command to expand all of them:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Forms![FormName]![SubFormName].Form.SubdatasheetExpanded = True&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;However, we often want only &lt;em&gt;some&lt;/em&gt; of the subdatasheets to be expanded, based on     &lt;br /&gt;some criteria (for example - expand only if subdatasheets contain data.) &lt;/p&gt;  &lt;p&gt;Watch a short video demo and download a demo database &lt;a href="http://sites.google.com/site/msaccesscode/forms-1/expandonesubformlineindatasheetviewcriteriabased" target="_blank"&gt;from this page&lt;/a&gt;. Make sure you have added a reference to the &amp;quot;Accessibility&amp;quot; library (%windir%\system32\oleacc.dll). &lt;/p&gt;  &lt;p&gt;This has been tested on Access 2007.&lt;/p&gt;  &lt;h6&gt;Send your Power Tips to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;.&lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9910662" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/User+Interface/default.aspx">User Interface</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Nulls vs. zero-length strings: a Power Tip from the past</title><link>http://blogs.msdn.com/access/archive/2009/10/14/nulls-vs-zero-length-strings-a-power-tip-from-the-past.aspx</link><pubDate>Wed, 14 Oct 2009 18:48:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907281</guid><dc:creator>cdowns</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/access/comments/9907281.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9907281</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today's guest blogger is Access MVP Garry Robinson, who offers the Smart Access collection of articles at &lt;/strong&gt;&lt;a href="http://www.vb123.com/kb"&gt;&lt;strong&gt;http://www.vb123.com/kb&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;A few months ago I purchased the rights to publish the Smart Access magazine online and it is from that collection that I offer this tip from Paul Litwin, the first editor of Smart Access. At the end of that I provide a link to an editorial on Null Values written by the second editor Peter Vogel. It never hurts to get a refresher course on Null values, a necessary evil for database developers.&lt;/p&gt;  &lt;h5&gt;Tip by Paul Litwin from 1997 &lt;/h5&gt;  &lt;p&gt;Even though Access considers Nulls and zero-length strings (ZLS) separate values, often developers wish to treat them as equivalent for the sake of an &lt;strong&gt;If...Then&lt;/strong&gt; statement or some other stretch of code. One way to accomplish this is to write code like this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;' Not so efficient &lt;/span&gt;
&lt;span class="kwrd"&gt;If&lt;/span&gt; IsNull(varAge) &lt;span class="kwrd"&gt;or&lt;/span&gt; varAge = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;
     &lt;span class="rem"&gt;' do something &lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;A better way to do this is:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;' More efficient &lt;/span&gt;
&lt;span class="kwrd"&gt;If&lt;/span&gt; Len(varAge &amp;amp; &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;) = 0 &lt;span class="kwrd"&gt;Then&lt;/span&gt;
     &lt;span class="rem"&gt;' do something &lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This second version of the code is more efficient for two reasons. First, if &lt;strong&gt;varAge&lt;/strong&gt; is Null, the code converts it into a ZLS by appending a ZLS to it. This lets us replace two tests with one. Second, it’s simply more efficient to check for a ZLS using Len(ZLS) = 0 rather than ZLS=&amp;quot;&amp;quot;.&lt;/p&gt;

&lt;p&gt;You can use a variation of this technique if you ever need to place the value of a text box or a variant variable into a string. Strings can’t contain Null values, so you may be tempted to write code like this that first checks to see if the text box is Null:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;' Another correct but slow method &lt;/span&gt;
&lt;span class="kwrd"&gt;If&lt;/span&gt; IsNull(txtAge) &lt;span class="kwrd"&gt;Then&lt;/span&gt;
     strAge = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt; 
&lt;span class="kwrd"&gt;Else&lt;/span&gt;     
     strAge = txtAge 
&lt;span class="kwrd"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;A much faster way to do this is to use code like this instead:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;' This is faster &lt;/span&gt;
strAge = txtAge &amp;amp; &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This code avoids doing the test altogether by setting the value to the concatenation of the text box and a ZLS. If the text box is Null, this converts it into a ZLS. If the text box is either a ZLS or a regular value, then the concatenation has no effect. &lt;/p&gt;

&lt;p&gt;Read more on Nulls in Peter Vogels editorial here &lt;a href="http://www.vb123.com/kb/200207_pv_ed.htm"&gt;http://www.vb123.com/kb/200207_pv_ed.htm&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9907281" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>3 new articles available on MSDN</title><link>http://blogs.msdn.com/access/archive/2009/10/05/3-new-articles-available-on-msdn.aspx</link><pubDate>Mon, 05 Oct 2009 18:40:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9903283</guid><dc:creator>cdowns</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/access/comments/9903283.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9903283</wfw:commentRss><description>&lt;p&gt;MSDN writer Sal Ricciardi alerted us to the availability of 3 new articles on MSDN, two written by Luke Chung of &lt;a href="http://www.fmsinc.com/" target="_blank"&gt;FMS Inc.&lt;/a&gt;, and one co-written by Luke Chung and Dan Haught. &lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="459"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="321"&gt;&lt;strong&gt;Title&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="136"&gt;&lt;strong&gt;Author(s)&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="321"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd942824.aspx " target="_blank"&gt;Performance Tips To Speed Up Your Access 2007 Database&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="136"&gt;Luke Chung and Dan Haught&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="321"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee358847.aspx " target="_blank"&gt;Error Handling and Debugging Tips for Access 2007, VB, and VBA&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="136"&gt;Luke Chung&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="321"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd638587.aspx " target="_blank"&gt;Tips and Techniques for Queries in Access 2007&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="136"&gt;Luke Chung&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Definitely bookmark these for future reference!&lt;/p&gt;  &lt;h6&gt;Send your Power Tips to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;.&lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903283" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category><category domain="http://blogs.msdn.com/access/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.msdn.com/access/archive/tags/Queries/default.aspx">Queries</category><category domain="http://blogs.msdn.com/access/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>Dynamically Resize a Subform Based on the Record Count</title><link>http://blogs.msdn.com/access/archive/2009/09/30/dynamically-resize-a-subform-based-on-the-record-count.aspx</link><pubDate>Wed, 30 Sep 2009 23:53:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9901497</guid><dc:creator>Mike Stowe</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/access/comments/9901497.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9901497</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today’s guest blogger is Vinny Malanga. Vinny is the CTO of &lt;a href="http://www.imisoftwareinc.com/"&gt;IMI Software, Inc.&lt;/a&gt; , which specializes in software development for the real estate and property management industries.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Many Access developers implement subforms to display data. Most often, at design time, the developer sets the subform to a specific size. In many cases this is fine, but there are some instances where it would be preferable to dynamically resize the subform at runtime, based on the number of records that it contains, up to a maximum number. Once the maximum number of records is reached, a vertical scroll bar should appear allowing the user to scroll through the rest of the records. The maximum number is arbitrary and simply used to prevent the subform from exceeding a certain height.&lt;/p&gt;  &lt;p&gt;I’ve provided a sample database that you can download &lt;a href="http://cid-f83d4d33f0a1a23a.skydrive.live.com/self.aspx/Sample%20Databases/ResizeSubForm.accdb"&gt;here&lt;/a&gt;. The database contains a table, two forms - a parent form and a subform - and a module with the resize method. &lt;/p&gt;  &lt;p&gt;In short, when the parent form loads, it calls a function on the subform which handles the resizing. It first retrieves the height of the header, footer and detail section of the subform. From there the subform is resized based on the height of the header, the height of the footer, and the height of the detail times the number of records. There are a couple of twips added to the total number to even out the border around the subform. Next, the record count of the underlying data source is retrieved. If the record count is greater than the maximum number of records you’ve defined, the ScrollBars property of the subform is set to 2 (Vertical Only), otherwise 0 or None. Lastly, in case there are any controls that exist under the subform, another function is called which repositions those controls based on the calculated height of the subform. &lt;/p&gt;  &lt;p&gt;I hope some of you find this technique useful.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9901497" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Tracing Function Calls in VBA</title><link>http://blogs.msdn.com/access/archive/2009/09/24/tracing-function-calls-in-vba.aspx</link><pubDate>Thu, 24 Sep 2009 20:36:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899067</guid><dc:creator>Mike Stowe</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/access/comments/9899067.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9899067</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today’s guest blogger is Joel Graff. Joel is a field engineer with the &lt;a href="http://www.dot.state.il.us/"&gt;Illinois Department of Transportation (IDOT)&lt;/a&gt;. &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Often, I find when looking for the source of an error in VBA code, a function call trace which returns the path of function calls preceding the error to be invaluable. While more complete compilers provide this feature as a part of the IDE, it is, unfortunately, absent in VBA. To accommodate this, I’ve written my own function call stack classes to help me trace errors. This implementation is based on something I found online, though I have since lost the reference. I cannot give credit where credit is due, only note that the basic implementation is at least somewhat borrowed.&lt;/p&gt;  &lt;p&gt;There are two classes I use:&amp;#160; cErrStack and cErr.&lt;/p&gt;  &lt;p&gt;cErrStack – Instanced as a global object, this provides the stack for procedure names as they are called. Procedures are added / removed (pushed / popped) from the stack as they come in and go out of scope. When an error occurs, the stack then contains, in order, the procedures called up to the procedure in which the error occurred. The cErrStack object returns the procedure name in which the error occurred and the trace path of function calls preceding the error with the methods ErrorProcedure() and Trace(). For higher-level error handling (where error handling occurs at the form level or only in main procedures), the ErrorProcedure() and Trace() routines will not provide correct information. In these cases, ErrorProcedureHistory() and TraceHistory() should be used instead.&lt;/p&gt;  &lt;p&gt;cErr – Instanced at the procedure level, this object pushes the name of the procedure on the global error stack object (the cErrStack object). When the procedure terminates, the cErr object goes out of scope, triggering its Terminate() Event. This event then removes (pops) the terminating procedure’s name from the global error stack.&lt;/p&gt;  &lt;p&gt;A sample error message may look like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/TracingFunctionCallsinVBA_F405/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/TracingFunctionCallsinVBA_F405/clip_image002_thumb.jpg" width="384" height="153" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Often, when I deploy a new database that hasn’t had all the bugs worked out, I write my error handling routine to automatically open an email and paste the above information into it. That way, users can send me the relevant error information automatically. I also use line numbers to help better identify problem code, though I didn’t implement them in this example.&lt;/p&gt;  &lt;p&gt;The original implementation only allowed for trace information to be available in the procedure in which the error occurred. That is, if an error occurred in a function with no error handling, then by the time the error was passed back to the procedure which did handle it, the stack would no longer have accurate trace information. However, as one Access user pointed out to me, adding error trapping code to every function creates a lot of code bloat and isn’t really necessary. Better code practices suggest use of “high-level” error trapping – trapping in main functions or at the form level. To accommodate “high-level” error trapping, I added a second stack to the cErrStack class, which contains a “trace history”. &lt;/p&gt;  &lt;p&gt;The idea is simple: When an error occurs in a function with no handling, the error is passed up the line until it is handled. That means that once an error occurs in higher level error handling, a “history” needs to be preserved until the error is handled. The class object does this by copying the contents of the immediate stack to the history stack when a “pop” occurs, and simply reassigning the history stack to the immediate stack when a “push” occurs. Thus, when an error occurs and is passed up the line to the handling procedure (a series of “pops” occur on the immediate stack), the history stack is preserved. Once a push occurs on the immediate stack (which presumably won’t happen until after the error is handled) the history stack is destroyed and referenced to the immediate stack.&lt;/p&gt;  &lt;p&gt;Attached is a sample of how the application works. There are three scenarios. The first two (“Lefthand Error” and “Righthand Error”) are “immediate” error handling examples. The last one is a high-level error handling example.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/TracingFunctionCallsinVBA_F405/clip_image002%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002[4]" border="0" alt="clip_image002[4]" src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/TracingFunctionCallsinVBA_F405/clip_image002%5B4%5D_thumb.jpg" width="324" height="159" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click the icon below to download the sample classes.&lt;/p&gt; &lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-f83d4d33f0a1a23a.skydrive.live.com/embedicon.aspx/Sample%20Databases/Error%20Trapping%20Demo.accdb" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;h6&gt;Send your Power Tips to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;.&lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899067" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Switch the Property Sheet on and off from VBA</title><link>http://blogs.msdn.com/access/archive/2009/09/23/switch-the-property-sheet-on-and-off-from-vba.aspx</link><pubDate>Wed, 23 Sep 2009 22:17:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9898605</guid><dc:creator>cdowns</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/access/comments/9898605.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9898605</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today's guest blogger is Pavlo Pedan of ARGO Business Corp. He has 15 years of experience with Access and has a great site of tips&amp;#160; at &lt;/strong&gt;&lt;a href="http://sites.google.com/site/msaccesscode/"&gt;&lt;strong&gt;http://sites.google.com/site/msaccesscode/&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When you open a form or report in Design View, the Property Sheet is either displayed or hidden based on its state the last time you left Design view. However, you might want to ensure that the Property Sheet is &lt;em&gt;always&lt;/em&gt; displayed (or hidden) when you switch to Design view. You might think to use the following command:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;DoCmd.RunCommand acCmdProperties&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Unfortunately, this command only works after the form or report is already open in Design View. To ensure that the Property Sheet is always displayed or hidden when you switch to Design view, use the function below. The function can be executed while starting an application (for example in the AutoExec macro), attached to the &lt;strong&gt;Close&lt;/strong&gt; event of the form or report, or whenever necessary. &lt;/p&gt;  &lt;p&gt;For example, you might use the function to suppress the blinking of the Property Sheet when creating a form at a run-time using the Application.CreateForm method and opening it in a Form view. &lt;/p&gt;  &lt;p&gt;Here's the code, which has been tested in Access 2007.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;'----------------------------------------------------------------&lt;/span&gt;
&lt;span class="rem"&gt;' Module    : modSwitchPropertySheet&lt;/span&gt;
&lt;span class="rem"&gt;' Author    : Pavlo Pedan&lt;/span&gt;
&lt;span class="rem"&gt;' Date      : 31/07/2009&lt;/span&gt;
&lt;span class="rem"&gt;' Purpose   : DoCmd.RunCommand acCmdProperties only toggles Property Sheet in&lt;/span&gt;
&lt;span class="rem"&gt;'           : Form/Report Design View on/off. Use function below to turn it&lt;/span&gt;
&lt;span class="rem"&gt;'           : on or off&lt;/span&gt;
&lt;span class="rem"&gt;'----------------------------------------------------------------&lt;/span&gt;

&lt;span class="kwrd"&gt;Option&lt;/span&gt; Compare Database

&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Declare&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; FindWindowEx &lt;span class="kwrd"&gt;Lib&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;User32&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;Alias&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;FindWindowExA&amp;quot;&lt;/span&gt; _
    (&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hwndParent &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hwndChildAfter &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;, _
     &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lpszClass &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; lpszWindow &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;

&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Declare&lt;/span&gt; &lt;span class="kwrd"&gt;Function&lt;/span&gt; GetWindowRect &lt;span class="kwrd"&gt;Lib&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;User32&amp;quot;&lt;/span&gt; (&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; hWnd &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;, _
    lpRect &lt;span class="kwrd"&gt;As&lt;/span&gt; RECT) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;

&lt;span class="kwrd"&gt;Private&lt;/span&gt; Type RECT
    Left &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;
    Top &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;
    Right &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;
    Bottom &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; Type

&lt;span class="kwrd"&gt;Function&lt;/span&gt; fSwitchPropertySheet(blnON &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;) &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;
&lt;span class="rem"&gt;'----------------------------------------------------------------&lt;/span&gt;
&lt;span class="rem"&gt;' Procedure : fSwitchPropertySheet&lt;/span&gt;
&lt;span class="rem"&gt;' Author    : Pavlo Pedan&lt;/span&gt;
&lt;span class="rem"&gt;' Date      : 31/07/2009&lt;/span&gt;
&lt;span class="rem"&gt;' Purpose   : switch Property Sheet in Design View (blnON = False to turn off)&lt;/span&gt;
&lt;span class="rem"&gt;'----------------------------------------------------------------&lt;/span&gt;

    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; frm &lt;span class="kwrd"&gt;As&lt;/span&gt; Form
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; hWnd &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;
    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; rectControl &lt;span class="kwrd"&gt;As&lt;/span&gt; RECT

    &lt;span class="rem"&gt;' create temp form&lt;/span&gt;
    &lt;span class="kwrd"&gt;Set&lt;/span&gt; frm = CreateForm

    &lt;span class="rem"&gt;' find handle for Property Sheet window&lt;/span&gt;
    hWnd = FindWindowEx(Application.hWndAccessApp, 0, &lt;span class="str"&gt;&amp;quot;MsoCommandBarDock&amp;quot;&lt;/span&gt;, _
        &lt;span class="str"&gt;&amp;quot;MsoDockRight&amp;quot;&lt;/span&gt;)
    &lt;span class="kwrd"&gt;If&lt;/span&gt; hWnd &amp;gt; 0 &lt;span class="kwrd"&gt;Then&lt;/span&gt;

        &lt;span class="rem"&gt;' get coordinates of the window&lt;/span&gt;
        GetWindowRect hWnd, rectControl
        &lt;span class="rem"&gt;' determine action&lt;/span&gt;
        &lt;span class="kwrd"&gt;If&lt;/span&gt; blnON &lt;span class="kwrd"&gt;Then&lt;/span&gt;
            &lt;span class="rem"&gt;' if window width is 0, switch it ON&lt;/span&gt;
            &lt;span class="kwrd"&gt;If&lt;/span&gt; rectControl.Left = rectControl.Right &lt;span class="kwrd"&gt;Then&lt;/span&gt;
                DoCmd.RunCommand acCmdProperties

                &lt;span class="rem"&gt;'returns True if action made&lt;/span&gt;
                fSwitchPropertySheet = &lt;span class="kwrd"&gt;True&lt;/span&gt;
            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
        &lt;span class="kwrd"&gt;Else&lt;/span&gt;
            &lt;span class="rem"&gt;' if window width is not 0, switch it OFF&lt;/span&gt;
            &lt;span class="kwrd"&gt;If&lt;/span&gt; rectControl.Left &amp;lt;&amp;gt; rectControl.Right &lt;span class="kwrd"&gt;Then&lt;/span&gt;
                DoCmd.RunCommand acCmdProperties

                &lt;span class="rem"&gt;'returns True if action made&lt;/span&gt;
                fSwitchPropertySheet = &lt;span class="kwrd"&gt;True&lt;/span&gt;
            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;
        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;

    &lt;span class="rem"&gt;' close temp form without saving&lt;/span&gt;
    DoCmd.Close , , acSaveNo

&lt;span class="kwrd"&gt;End&lt;/span&gt; Function&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;

&lt;h6&gt;Send your Power Tips to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;.&lt;/h6&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9898605" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Using VBA to Send Data to a Table from an Unbound Form Control</title><link>http://blogs.msdn.com/access/archive/2009/09/16/using-vba-to-send-data-to-a-table-from-an-unbound-form-control.aspx</link><pubDate>Wed, 16 Sep 2009 21:27:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895982</guid><dc:creator>Mike Stowe</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/access/comments/9895982.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9895982</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today’s guest author is Justin Farrell, author of the Access 2007 tutorial &lt;/strong&gt;&lt;a href="http://www.dealing-with-data.net"&gt;&lt;strong&gt;http://www.dealing-with-data.net&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This is a useful trick which gives the Access Developer additional flexibility when working with forms and data. It uses Access VBA and DAO.&lt;/p&gt;  &lt;p&gt;Once the user enters data into the unbound textbox (&lt;b&gt;txtBox&lt;/b&gt;) and clicks the &lt;b&gt;Send Data To Table&lt;/b&gt; button, Access opens a recordset based on the &lt;b&gt;tblTest &lt;/b&gt;table. The &lt;b&gt;txtBox&lt;/b&gt; data is then stored in a variable called &lt;b&gt;varTextData &lt;/b&gt;and then added to the &lt;b&gt;rst&lt;/b&gt; recordset. The recordset is updated and the txtBox control is reset ready for new data to be entered. The result is an unbound form that interacts with a database table.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; cmdSend_Click()

&lt;span class="kwrd"&gt;Dim&lt;/span&gt; db &lt;span class="kwrd"&gt;As&lt;/span&gt; DAO.Database
&lt;span class="kwrd"&gt;Dim&lt;/span&gt; rst &lt;span class="kwrd"&gt;As&lt;/span&gt; DAO.Recordset
&lt;span class="kwrd"&gt;Dim&lt;/span&gt; varTextData &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;

    varTextData = txtBox

    &lt;span class="kwrd"&gt;Set&lt;/span&gt; db = CurrentDb
    &lt;span class="kwrd"&gt;Set&lt;/span&gt; rst = db.OpenRecordset(&lt;span class="str"&gt;&amp;quot;tblTest&amp;quot;&lt;/span&gt;, dbOpenDynaset)

    rst.AddNew
    rst!fldTest = varTextData
    rst.Update
    rst.Close

    db.Close
    &lt;span class="kwrd"&gt;Me&lt;/span&gt;!txtBox = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;style type="text/css"&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Justin’s supplied a sample database that illustrates this technique. &lt;/p&gt;
&lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-f83d4d33f0a1a23a.skydrive.live.com/embedicon.aspx/Sample%20Databases/SendDataFromUnboundFormControlToTable.accdb" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;

&lt;h6&gt;&lt;strong&gt;Send your Power Tips to Mike &amp;amp; Chris at &lt;/strong&gt;&lt;a href="mailto:accpower@microsoft.com"&gt;&lt;strong&gt;accpower@microsoft.com&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9895982" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Table/default.aspx">Table</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>"Convert" a TextBox to a ComboBox at a run-time</title><link>http://blogs.msdn.com/access/archive/2009/09/14/convert-a-textbox-to-a-combobox-at-a-run-time.aspx</link><pubDate>Mon, 14 Sep 2009 20:27:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895053</guid><dc:creator>cdowns</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/access/comments/9895053.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9895053</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Today's guest blogger is Pavlo Pedan of ARGO Business Corp. He has 15 years of experience with Access and has a great site of tips&amp;#160; at &lt;/strong&gt;&lt;a href="http://sites.google.com/site/msaccesscode/"&gt;&lt;strong&gt;http://sites.google.com/site/msaccesscode/&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Some people do not like having ComboBoxes on a form because of drop-down buttons. &lt;a href="http://support.microsoft.com/kb/109724" target="_blank"&gt;Microsoft offers a solution here&lt;/a&gt;, but this approach does not work for a datasheet view – the drop-down button shows up when the ComboBox gets the focus. &lt;/p&gt;  &lt;p&gt;Some people do not like ComboBoxes because the control requires some time to be populated from its row source. The row source could be remote and/or could be based on complex calculations. On the other hand, we actually need selection features of ComboBox only while editing respective field. Often we do not need all    &lt;br /&gt;this overhead while simply navigating through records (unless we want to see data from a different column of the ComboBox).&lt;/p&gt;  &lt;p&gt;While a ComboBox can be populated dynamically while entering symbols (&lt;a href="http://allenbrowne.com/ser-32.html" target="_blank"&gt;see this great article from Allen Browne&lt;/a&gt;), the other approach is to get rid of the ComboBox itself while just displaying records and get it involved only when necessary. &lt;/p&gt;  &lt;p&gt;Please have a look at my short video demo and download the VirtualComboBoxDemo sample database &lt;a href="http://sites.google.com/site/msaccesscode/controls-2/converttextboxtocomboboxatarun-time" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;When left-clicked or Alt+Down is pressed, a pop-up non-modal form that contains only one ComboBox shows up exactly over the TextBox. The text part (with or without a dropdown button) can be hidden or made visible, and can be made to use the AutoCorrect feature or not (see the code for details). This approach works for both Form and Datasheet views. Not much VBA programming is required. The ComboBox &amp;quot;converts&amp;quot; back to a TextBox if you press ESC, Tab or Shift+Tab, or when you click somewhere on a main form. This emulates natural ComboBox behaviour. &lt;/p&gt;  &lt;p&gt;So now we have a form with TextBoxes only! When we need ComboBox, it appears on-the-fly and disappears when we are done with selection. This has been tested with Access 2007. &lt;/p&gt;  &lt;p&gt;The usage of the clsControlLayout class is explained &lt;a href="http://sites.google.com/site/msaccesscode/controls-2/classclscontrollayoutallowstousecontrollocation" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;h6&gt;Send your Power Tips to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;.&lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9895053" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/User+Interface/default.aspx">User Interface</category><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Return a Limited Number of Rows on a Criteria Form</title><link>http://blogs.msdn.com/access/archive/2009/07/15/returning-a-limited-number-of-rows-on-a-criteria-form.aspx</link><pubDate>Thu, 16 Jul 2009 09:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9834727</guid><dc:creator>Mike Stowe</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/access/comments/9834727.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9834727</wfw:commentRss><description>&lt;p&gt;&lt;b&gt;Today’s guest blogger is Alison Balter. Alison is the founder of &lt;a mce_href="http://www.infotechservicesgroup.com/index.htm" href="http://www.infotechservicesgroup.com/index.htm"&gt;InfoTech Services Group, Inc.&lt;/a&gt; and has authored &lt;a href="http://www.amazon.com/Alison-Balter/e/B001IO9NPK/"&gt;14 Access books&lt;/a&gt; since 1995.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;When working in a client/server environment, it is imperative that you limit the number of rows that the user brings over the network wire. It is therefore necessary that you supply a criteria form that allows the user to specify the rows that they want to return. The problem is that the user often designates criteria that is way too broad. In that situation, you must determine that there is a problem, and require the user to create criteria that returns less rows. An example is the form shown below.&lt;/p&gt;  &lt;p&gt;&lt;a mce_href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_10.png" href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" mce_src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_thumb_4.png" width="540" height="343" src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_thumb_4.png"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see, the user first selects from a Search For combo box to designate the field within they wish to search. They then determine whether they are looking for the criteria as an exact match, starts with, or whether the search string is contained within the field. If the user enters criteria that returns over 500 rows, the message box below appears.&lt;/p&gt;  &lt;p&gt;&lt;a mce_href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_4.png" href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" mce_src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_thumb_1.png" width="244" height="87" src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_thumb_1.png"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The user must narrow their criteria and try again. The exception to this is if the field being searched is either the Vendor Used Cage Code or the Requested Cage Code. In that case the message shown below appears, and only the top 500 rows appear.&lt;/p&gt;  &lt;p&gt;&lt;a mce_href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_6.png" href="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" mce_src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_thumb_2.png" width="244" height="118" src="http://blogs.msdn.com/blogfiles/access/WindowsLiveWriter/ReturningaLimitedNumberofRowsonaCriteria_C2EC/image_thumb_2.png"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The code below accomplishes all of the functionality described above.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; SearchProjects()    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strFieldToSearch &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strValueToSearch &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strOperatorToSearch &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strWhereClause &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strWhereClauseSQL &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strWhereClause_Acct &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; strWhereClauseSQL_Acct &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;        &lt;span class="rem"&gt;'Declare recordset used to hold the count of rows returned from the server&lt;/span&gt;    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; rst &lt;span class="kwrd"&gt;As&lt;/span&gt; ADODB.Recordset    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; lngRowCount &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;        strFieldToSearch = &lt;span class="kwrd"&gt;Me&lt;/span&gt;.cboSearchFor.Value    strValueToSearch = &lt;span class="kwrd"&gt;Me&lt;/span&gt;.txtFindItem    strOperatorToSearch = &lt;span class="kwrd"&gt;Me&lt;/span&gt;.cboSearchWithText.Value        &lt;span class="rem"&gt;'Evaluate whether the user has selected Starts With, Exact Match, or Contains&lt;/span&gt;    &lt;span class="kwrd"&gt;Select&lt;/span&gt; &lt;span class="kwrd"&gt;Case&lt;/span&gt; strOperatorToSearch        &lt;span class="kwrd"&gt;Case&lt;/span&gt; &lt;span class="str"&gt;"S"&lt;/span&gt;   &lt;span class="rem"&gt;'Starts With&lt;/span&gt;            strWhereClause = strFieldToSearch &amp;amp; &lt;span class="str"&gt;" Like '"&lt;/span&gt; &amp;amp; _                strValueToSearch &amp;amp; &lt;span class="str"&gt;"*'"&lt;/span&gt;            strWhereClauseSQL = strFieldToSearch &amp;amp; &lt;span class="str"&gt;" Like '"&lt;/span&gt; &amp;amp; _                strValueToSearch &amp;amp; &lt;span class="str"&gt;"%'"&lt;/span&gt;        &lt;span class="kwrd"&gt;Case&lt;/span&gt; &lt;span class="str"&gt;"E"&lt;/span&gt;   &lt;span class="rem"&gt;'Exact Match&lt;/span&gt;            strWhereClause = strFieldToSearch &amp;amp; &lt;span class="str"&gt;" = '"&lt;/span&gt; &amp;amp; _                strValueToSearch &amp;amp; &lt;span class="str"&gt;"'"&lt;/span&gt;            strWhereClauseSQL = strFieldToSearch &amp;amp; &lt;span class="str"&gt;" = '"&lt;/span&gt; &amp;amp; _                strValueToSearch &amp;amp; &lt;span class="str"&gt;"'"&lt;/span&gt;        &lt;span class="kwrd"&gt;Case&lt;/span&gt; &lt;span class="str"&gt;"A"&lt;/span&gt;   &lt;span class="rem"&gt;'Contains&lt;/span&gt;            strWhereClause = strFieldToSearch &amp;amp; &lt;span class="str"&gt;" Like '*"&lt;/span&gt; &amp;amp; _                strValueToSearch &amp;amp; &lt;span class="str"&gt;"*'"&lt;/span&gt;            strWhereClauseSQL = strFieldToSearch &amp;amp; &lt;span class="str"&gt;" Like '%"&lt;/span&gt; &amp;amp; _                strValueToSearch &amp;amp; &lt;span class="str"&gt;"%'"&lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Select&lt;/span&gt;        &lt;span class="kwrd"&gt;Set&lt;/span&gt; rst = &lt;span class="kwrd"&gt;New&lt;/span&gt; ADODB.Recordset    rst.ActiveConnection = CurrentProject.Connection        &lt;span class="rem"&gt;'Open the recordset, returning the count of ProjectID&lt;/span&gt;    &lt;span class="rem"&gt;'from vwSearchRequisitions based on the criteria the user has designated&lt;/span&gt;    rst.Open &lt;span class="str"&gt;"SELECT COUNT(ProjectID_Projects) AS NumRows "&lt;/span&gt; &amp;amp; _        &lt;span class="str"&gt;"FROM vwSearchRequisitions WHERE "&lt;/span&gt; &amp;amp; strWhereClauseSQL        lngRowCount = rst!NumRows        rst.Close        &lt;span class="rem"&gt;'If the count returned from the server is less than or equal to 500,&lt;/span&gt;    &lt;span class="rem"&gt;'all is well, and the data is displayed in the appropriate subforms&lt;/span&gt;    &lt;span class="kwrd"&gt;If&lt;/span&gt; lngRowCount &amp;lt;= 500 &lt;span class="kwrd"&gt;Then&lt;/span&gt;            &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchRequisitions.Form.RecordSource = _            &lt;span class="str"&gt;"SELECT * FROM vwSearchRequisitions WHERE "&lt;/span&gt; &amp;amp; _            strWhereClause &amp;amp; &lt;span class="str"&gt;" ORDER BY EnteredOn DESC"&lt;/span&gt;        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchRequisitions.Form.Requery        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchRFQ.Form.RecordSource = _            &lt;span class="str"&gt;"SELECT * FROM vwSearchRequisitions WHERE ("&lt;/span&gt; &amp;amp; _            strWhereClause &amp;amp; &lt;span class="str"&gt;") AND ProjectID_RFQ IS NOT NULL"&lt;/span&gt; &amp;amp; _            &lt;span class="str"&gt;" ORDER BY EnteredOn DESC"&lt;/span&gt;        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchRFQ.Form.Requery        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchBid.Form.RecordSource = _            &lt;span class="str"&gt;"SELECT * FROM vwSearchRequisitions WHERE ("&lt;/span&gt; &amp;amp; _            strWhereClause &amp;amp; &lt;span class="str"&gt;") AND ProjectID_BID IS NOT NULL"&lt;/span&gt; &amp;amp; _            &lt;span class="str"&gt;" ORDER BY EnteredOn DESC"&lt;/span&gt;        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchBid.Form.Requery        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchAcct.Form.RecordSource = _            &lt;span class="str"&gt;"SELECT * FROM vwSearchRequisitions WHERE ("&lt;/span&gt; &amp;amp; _            strWhereClause &amp;amp; &lt;span class="str"&gt;") AND ProjectID_Acct IS NOT NULL"&lt;/span&gt; &amp;amp; _            &lt;span class="str"&gt;" ORDER BY EnteredOn DESC"&lt;/span&gt;        &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchAcct.Form.Requery    &lt;span class="kwrd"&gt;Else&lt;/span&gt;        &lt;span class="rem"&gt;'If the search returned more than 500 rows, but the user is searching for&lt;/span&gt;        &lt;span class="rem"&gt;'Vendor Used Cage Code or Requested Cage Code, return the top 500 rows.&lt;/span&gt;        &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Me&lt;/span&gt;.cboSearchFor.Column(0) = &lt;span class="str"&gt;"Vendor Used Cage Code"&lt;/span&gt; &lt;span class="kwrd"&gt;Or&lt;/span&gt; _            &lt;span class="kwrd"&gt;Me&lt;/span&gt;.cboSearchFor.Column(0) = &lt;span class="str"&gt;"Requested Cage Code"&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;            MsgBox &lt;span class="str"&gt;"Data Being Reduced to 500 Most Recent Rows"&lt;/span&gt;, _                vbInformation, &lt;span class="str"&gt;"Warning"&lt;/span&gt;            &lt;span class="kwrd"&gt;Me&lt;/span&gt;.fsubSearchAcct.Form.RecordSource = _                &lt;span class="str"&gt;"SELECT TOP 500 EnteredOn, ProjectID_Projects, "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"ExpiresOn, ProsIDNum, "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"SnapReqID, GeneralReqID, CustFileNum, ReqCageCode "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"ReqVendor, PNNum, NSN, Qty, UOM, PartDesc, "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"GROUP BY EnteredOn, ProjectID_Projects, "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"ExpiresOn, ProsIDNum, "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"SnapReqID, GeneralReqID, CustFileNum, ReqCageCode "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"ReqVendor, PNNum, NSN, Qty, UOM, PartDesc, "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"HAVING ("&lt;/span&gt; &amp;amp; strWhereClause &amp;amp; _                    &lt;span class="str"&gt;") AND ProjectID_Acct IS NOT NULL ORDER BY EnteredOn DESC "&lt;/span&gt;        &lt;span class="kwrd"&gt;Else&lt;/span&gt;            &lt;span class="rem"&gt;'For any other field display a message that the criteria must be narrowed&lt;/span&gt;            MsgBox &lt;span class="str"&gt;"Your Criteria is Returning Too Many Rows. "&lt;/span&gt; &amp;amp; _                    &lt;span class="str"&gt;"Narrow Your Criteria and Try Again"&lt;/span&gt;, vbExclamation, _                    &lt;span class="str"&gt;"Please Try Again"&lt;/span&gt;            &lt;span class="kwrd"&gt;Exit&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{	font-size: small;	color: black;	font-family: consolas, "Courier New", courier, monospace;	background-color: #ffffff;	/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {	background-color: #f4f4f4;	width: 100%;	margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;The code first determines whether the user has selected Starts With, Exact Match, or Contains. Note that regardless of their choice, the code sets the value of two variables: strWhereClause and strWhereClauseSQL. It must do this because the SELECT COUNT is executed on the server. SQL Server does not understand the asterisk (*). It is therefore necessary to create a variable with the percent (%) sign, the wildcard in SQL Server.&lt;/p&gt;&lt;p&gt;Now the code is ready to open the recordset, returning the count into lngRowCount. Next the code evaluates lngRowCount. If it is less than or equal to 500, all is well, and the data is displayed in a datasheet. The data is based on a vwSearchRequisitions with the appropriate WHERE clause applied (based on the selected criteria).&lt;/p&gt;&lt;p&gt;If the search returned more than 500 rows, but the field being searched was either Vendor Used Cage Code or Requested Cage Code, a message box appears warning the user that only the top 500 rows will appear in the datasheet, and then SELECT TOP 500 is used to return the appropriate rows.&lt;/p&gt;&lt;p&gt;Finally, if the user is searching any other field, and the number of rows returned is greater than or equal to 500, a message appears, and the search is aborted.&lt;/p&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{	font-size: small;	color: black;	font-family: consolas, "Courier New", courier, monospace;	background-color: #ffffff;	/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {	background-color: #f4f4f4;	width: 100%;	margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9834727" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Case-Sensitive string comparisons</title><link>http://blogs.msdn.com/access/archive/2009/06/26/case-sensitive-string-comparisons.aspx</link><pubDate>Fri, 26 Jun 2009 19:56:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9805692</guid><dc:creator>cdowns</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/access/comments/9805692.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9805692</wfw:commentRss><description>&lt;h5&gt;Today’s guest blogger is Michael Groh, co-author of the popular &lt;a href="http://www.amazon.com/Access-2007-Bible-Michael-Groh/dp/0470046732/"&gt;Access 2007 Bible&lt;/a&gt;.&lt;/h5&gt;  &lt;p&gt;The VBA language is not, by default, case-sensitive. A statement such as &lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; CBool(&amp;quot;XYZ&amp;quot; = &amp;quot;xyz&amp;quot;) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;will always return True. You might come across this issue in cases such as the following:&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;If strOne = strTwo Then&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; ' Perform some operation here&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;End If&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Consider what happens if it's important to know that the strings differ only by case. By default, VBA will never report a difference in the strings based only on the case applied to the string variables.&lt;/p&gt;  &lt;p&gt;One easy fix is to use the &lt;strong&gt;InStrB&lt;/strong&gt; (&amp;quot;in string byte&amp;quot;) function, which considers the strings based on byte value (where &amp;quot;x&amp;quot; is different than &amp;quot;X&amp;quot;). By contrast, the &lt;strong&gt;InStr&lt;/strong&gt; function considers just character value (&amp;quot;x&amp;quot; is the same as &amp;quot;X&amp;quot;). &lt;/p&gt;  &lt;p&gt;The transformed If statement becomes:&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; If CBool(InStrB(strOne, strTwo)) Then...&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This statement takes the output of InStrB() and converting it to a Boolean (True or False) expression. When InStrB returns 0 (no match found), CBool converts the expression's value to False. If InStrB finds the strings match (by case and by character) the expression evaluates to True.&lt;/p&gt;  &lt;p&gt;You'll find that using the InStrB() function is much faster and easier than writing a VBA function that parses each string and does a binary or ASCII comparison on each character in both strings.&lt;/p&gt;  &lt;h6&gt;Get your favorite Power Tip on the blog! Send it to Mike and Chris at &lt;a href="mailto:accpower@microsoft.com"&gt;accpower@microsoft.com&lt;/a&gt;. &lt;/h6&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9805692" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Counting the days…</title><link>http://blogs.msdn.com/access/archive/2009/06/09/counting-the-days.aspx</link><pubDate>Wed, 10 Jun 2009 07:38:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9723339</guid><dc:creator>cdowns</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/access/comments/9723339.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9723339</wfw:commentRss><description>&lt;p&gt;Sal Ricciardi of the Access Developer Documentation team has produced a couple of articles for MSDN that address two commonly-asked date-related questions about Access: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd633614.aspx" target="_blank"&gt;Using Excel Date Functions in Access 2007&lt;/a&gt; shows how to use Excel’s &lt;strong&gt;NETWORKDAYS&lt;/strong&gt; function from within Access.&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd327646.aspx" target="_blank"&gt;Counting the Number of Working Days in Access 2007&lt;/a&gt; describes how you can create the &lt;strong&gt;Weekdays&lt;/strong&gt; and &lt;strong&gt;Workdays&lt;/strong&gt; user-defined functions to count the number of working days between two dates.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Thanks Sal!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9723339" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item><item><title>Sample Class Eases Creation of Similar Forms</title><link>http://blogs.msdn.com/access/archive/2009/06/05/sample-class-eases-creation-of-similar-forms.aspx</link><pubDate>Sat, 06 Jun 2009 01:40:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9702181</guid><dc:creator>Mike Stowe</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/access/comments/9702181.aspx</comments><wfw:commentRss>http://blogs.msdn.com/access/commentrss.aspx?PostID=9702181</wfw:commentRss><description>&lt;p&gt;Last week Joel Graff &lt;a href="http://blogs.msdn.com/access/archive/2009/05/28/access-proves-worth-its-salt-for-idot.aspx"&gt;shared his story on how he used Access to track salt usage&lt;/a&gt; for the Illinois Department of Transportation. Some of you wanted to know more about the custom class that he uses to ease the creation of similar forms. &lt;/p&gt;  &lt;p&gt;Joel has agreed to share a sample implementation of his custom class.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;It basically uses three interrelated lookup tables to demonstrate the class with varying degrees of complexity (three different examples). I made use of the nifty article on writing help using reports to provide some information on how it performs. I’m no guru at interfaces / tutorial writing, but hopefully what I’ve sent is a sufficient example.&lt;/p&gt;    &lt;p&gt;I suppose it's homebrewed enough anyone who knows better would get a chuckle or two off of it, but I'd love to see what someone else thinks.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You can download Joel’s sample database &lt;a href="http://cid-f83d4d33f0a1a23a.skydrive.live.com/self.aspx/Sample%20Databases/SubtableForm.accdb"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9702181" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/access/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/access/archive/tags/Form/default.aspx">Form</category><category domain="http://blogs.msdn.com/access/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/access/archive/tags/Power+Tips/default.aspx">Power Tips</category></item></channel></rss>