<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-34083602</atom:id><lastBuildDate>Thu, 09 Jul 2009 08:35:04 +0000</lastBuildDate><title>LEARN MS-ACCESS TIPS AND TRICKS</title><description>Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.</description><link>http://www.msaccesstips.com/</link><managingEditor>noreply@blogger.com (a.p.r. pillai)</managingEditor><generator>Blogger</generator><openSearch:totalResults>153</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/LearnMs-accessTipsAndTricks" type="application/rss+xml" /><feedburner:emailServiceId>LearnMs-accessTipsAndTricks</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5362449751902201953</guid><pubDate>Thu, 09 Jul 2009 07:26:00 +0000</pubDate><atom:updated>2009-07-09T12:35:04.955+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess reporttricks</category><title>Hiding Report Lines Conditionally-3</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/p-B-_8bDd0IEEMiZtTrOdYX2w1Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p-B-_8bDd0IEEMiZtTrOdYX2w1Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/p-B-_8bDd0IEEMiZtTrOdYX2w1Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p-B-_8bDd0IEEMiZtTrOdYX2w1Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;This is the continuation of two Articles published earlier on this Subject. You may go through them by following the links given below before continuing from here. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2009/06/hiding-report-lines-conditionally.shtml"&gt;Hiding Report Lines Conditionally&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2009/07/hiding-report-lines-conditionally-2.shtml"&gt;Hiding Report Lines Conditionally-2&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;We have learned how to hide &lt;a href="http://www.msaccesstips.com/2009/06/network-and-report-page-setup.shtml"&gt;Report&lt;/a&gt; items conditionally and calculate &lt;b&gt;Sub-Totals&lt;/b&gt; and Report &lt;b&gt;Footer Totals&lt;/b&gt; in Code by excluding values of those records we have removed from the Report &lt;b&gt;Detail Section&lt;/b&gt;. We have updated the calculated values in &lt;b&gt;Group Footer&lt;/b&gt; and &lt;b&gt;Report Footer&lt;/b&gt; Section Controls. &lt;br /&gt;&lt;br /&gt;We did this by checking for specific values in the Report Source Data and by &lt;b&gt;Canceling&lt;/b&gt; the &lt;b&gt;Format Event&lt;/b&gt; of the Report. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These exercises we have done on the &lt;b&gt;Detail Section&lt;/b&gt; alone earlier on the &lt;a href="http://www.msaccesstips.com/2009/06/network-and-print-page-setup-2.shtml"&gt;Report&lt;/a&gt; by hiding specific record.   But, here our focus is on hiding all records of a particular &lt;b&gt;Customer Group&lt;/b&gt; including the &lt;b&gt;Customer Group Header&lt;/b&gt;, &lt;b&gt;Group Footer&lt;/b&gt; and &lt;b&gt;Detail Sections&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you understood the method we have used in the last two examples then you will have no difficulty in understanding it here. The only difference here is to compare the Group Value (&lt;b&gt;CustomerID&lt;/b&gt;) in all the three Section&amp;#39;s (i.e. Group Header, Detail and Group Footer Sections) &lt;b&gt;Format Event Procedure&lt;/b&gt; to hide or show them rather than Report &lt;b&gt;Detail Section&lt;/b&gt; alone as we did in the earlier example.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Make a copy of the earlier &lt;a href="http://www.msaccesstips.com/2009/06/network-and-print-page-setup-3.shtml"&gt;Report&lt;/a&gt; (&lt;b&gt;Order_Details&lt;/b&gt;) and save it with the name &lt;b&gt;Order_Details2&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the Report in Design View.  We will make a small change on the &lt;b&gt;Group Footer&lt;/b&gt; Section. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Label with the Caption &lt;b&gt;Sub-Total&lt;/b&gt; to select it. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Change To&lt;/b&gt; from &lt;b&gt;Format&lt;/b&gt; Menu and select &lt;b&gt;Text Box&lt;/b&gt; from the displayed options. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://www.msaccesstips.com/2009/04/animating-label-on-search-success.shtml"&gt;Label&lt;/a&gt; Control we have now changed to a &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Box&lt;/a&gt;&lt;/b&gt; to write an expression to display the &lt;b&gt;CustomerID&lt;/b&gt; value of each Customer Group along with the earlier caption &lt;b&gt;Sub-Total&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet (&lt;b&gt;View- - &gt;Properties&lt;/b&gt;) of the Text Box. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Write the following Expression in the &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Control&lt;/a&gt; Source&lt;/b&gt; Property of the Text Box. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;font class=”colrgreen”&gt;=[CustomerID] &amp;amp; &amp;quot; Sub-Total: &amp;quot;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The result of this change will appear on the Report something like &lt;font class=”colrgreen”&gt;BSBEV Sub-Total: 123&lt;/font&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CustomerID&lt;/b&gt; code will be enough for our example here but when you design some Reports in your Projects then it should be something descriptive like the Customer Name rather than Customer Code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will be using this &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;Report&lt;/a&gt; for some other trick later, besides what we are going to do with it here, so take it seriously and you will know why it is so important.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the Report (&lt;b&gt;View - -&gt; Code&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Delete the existing Code from the Module. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into the Report Code Module and Save the Report. &lt;/li&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;Option Compare Database&lt;br /&gt;Dim x_subtot As Long, x_gtot As Long&lt;br /&gt;&lt;br /&gt;Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;If [CustomerID] = &amp;quot;BSBEV&amp;quot; Or [CustomerID] = &amp;quot;CENTC&amp;quot; Then&lt;br /&gt;   Cancel = True&lt;br /&gt;Else&lt;br /&gt;   Cancel = False&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;If [CustomerID] = &amp;quot;BSBEV&amp;quot; Or [CustomerID] = &amp;quot;CENTC&amp;quot; Then&lt;br /&gt;    Cancel = True&lt;br /&gt;Else&lt;br /&gt;    Cancel = False&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;    If PrintCount = 1 Then&lt;br /&gt;        x_subtot = x_subtot + [Quantity]&lt;br /&gt;        x_gtot = x_gtot + [Quantity]&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Sub GroupFooter0_print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;    If PrintCount = 1 Then&lt;br /&gt;        [subtot] = x_subtot&lt;br /&gt;        x_subtot = 0&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub ReportFooter_print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;If PrintCount = 1 Then&lt;br /&gt;    [gtot] = x_gtot&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;a href="http://www.msaccesstips.com/2007/09/ms-access-object-documenter.shtml"&gt;Report&lt;/a&gt; in Print Preview and check whether these &lt;b&gt;Customer Group Header, Detail &lt;/b&gt;and &lt;b&gt;Group Footer Sections&lt;/b&gt; are hidden from the Report or not.  Check the sample image given below.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msaccesstips.com/uploaded_images/hidinglines3-708316.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 274px; height: 320px;" src="http://www.msaccesstips.com/uploaded_images/hidinglines3-708313.jpg" border="0" alt="Report image showing Group Footer alone" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;From the VBA Code above we have purposely removed the Code for &lt;b&gt;Group Footer Format Event Procedure&lt;/b&gt; so that the Group Footer alone for the CustomerID &lt;b&gt;BSBEV&lt;/b&gt; and &lt;b&gt;CENTC &lt;/b&gt;will appear. We can now see the position of these Group items appearing on the Report and from where the &lt;b&gt;Group Header&lt;/b&gt; and &lt;b&gt;Detail Sections&lt;/b&gt; are hidden from our view. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Another point to note is that since we have &lt;b&gt;Canceled&lt;/b&gt; the &lt;b&gt;Format Event&lt;/b&gt; of the &lt;b&gt;Detail Section&lt;/b&gt; of these Customer Groups the &lt;b&gt;Print Event&lt;/b&gt; has not taken place for &lt;b&gt;Detail Section&lt;/b&gt;.  Because of this the Group Summary Totals for these two Customer Codes are showing as zeroes. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Copy the following Code and Paste it at the bottom of the Code Module and save the &lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Report&lt;/a&gt;.  &lt;br /&gt;&lt;pre class=”alt3”&gt;&lt;br /&gt;Private Sub GroupFooter0_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;     If [CustomerID] = &amp;quot;BSBEV&amp;quot; Or [CustomerID] = &amp;quot;CENTC&amp;quot; Then&lt;br /&gt;           Cancel = True&lt;br /&gt;     Else&lt;br /&gt;           Cancel = False&lt;br /&gt;     End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; If you are wondering how to name the &lt;b&gt;Sub-Routine&lt;/b&gt; and Parameters related to each Section of the Report correctly then stop worrying. This (the Subroutine header line and the End Sub lines) will be written by MS-Access. Click on the Section Header/Footer of the Report in design view, display the Property Sheet (&lt;b&gt;View - -&gt; Properties&lt;/b&gt;), set &lt;b&gt;Event Procedure&lt;/b&gt; on the &lt;b&gt;Format&lt;/b&gt; or &lt;b&gt;Print&lt;/b&gt; Event Property, Click on the build (&lt;b&gt;...&lt;/b&gt;) &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Button&lt;/a&gt; to the right edge of the Property Sheet. Both the Sub-Routine Name (pointing to the correct Section of the Report) with appropriate Parameter list and the &lt;b&gt;End Sub&lt;/b&gt; lines will open up in the Code Module of the Report.  You only need to write other lines between them manually.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Open the Report again in Print Preview and this time you will find the &lt;b&gt;Group Footer&lt;/b&gt; of these Customers are also hidden. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We are checking for the &lt;b&gt;CustomerlD&lt;/b&gt; Code &lt;b&gt;BSBEV&lt;/b&gt; and &lt;b&gt;CENTC&lt;/b&gt; in all the three Sections of the Report in the &lt;b&gt;Format Event Procedure&lt;/b&gt; to hide these Sections.  Once the &lt;b&gt;Format Action&lt;/b&gt; is  prevented from happening; the Print Event doesn&amp;#39;t take place and the Quantity Value of those items are not added to the Total. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you look at the Code structure carefully you can see that we are using the &lt;b&gt;Format Event&lt;/b&gt; as well as &lt;b&gt;Print Event Procedures&lt;/b&gt; for both &lt;b&gt;Detail Section&lt;/b&gt; and &lt;b&gt;Group Footer Sections&lt;/b&gt;.  &lt;b&gt;Format Action&lt;/b&gt; used for hiding or displaying the Report contents based on the criterion and &lt;b&gt;Print Action&lt;/b&gt; for Calculations or Updating the Group Total Controls.  We have used only &lt;b&gt;Print Event Procedure&lt;/b&gt; for &lt;b&gt;Report Footer&lt;/b&gt; Section.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next we will learn how to open the same Report in two different Modes, i.e. as a &lt;b&gt;Detail Report&lt;/b&gt; and as a &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Summary&lt;/a&gt; Report&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/07/hiding-report-lines-conditionally-3.shtml&amp;amp;title=Hiding+Report+Lines+Conditionally-3"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/03/change-form-modes-on-user-profile.shtml"&gt;Change Form Modes On User Profile&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/03/positioning-pop-up-forms.shtml"&gt;Positioning POPUP Forms&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Synchronized Floating Popup Form&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml"&gt;Forms and Custom Properties&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml"&gt;Control Tip Text and Time Delay&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5362449751902201953?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2xuZ8C8T-Uw:WM7_NP1YRPg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2xuZ8C8T-Uw:WM7_NP1YRPg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2xuZ8C8T-Uw:WM7_NP1YRPg:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2xuZ8C8T-Uw:WM7_NP1YRPg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2xuZ8C8T-Uw:WM7_NP1YRPg:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/2xuZ8C8T-Uw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/2xuZ8C8T-Uw/hiding-report-lines-conditionally-3.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/07/hiding-report-lines-conditionally-3.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-6126014601463320436</guid><pubDate>Fri, 03 Jul 2009 07:42:00 +0000</pubDate><atom:updated>2009-07-03T13:28:49.174+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess reporttricks</category><title>Hiding Report Lines Conditionally-2</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XtXFZLcYgxIao0vywLlrJLiUKvY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XtXFZLcYgxIao0vywLlrJLiUKvY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XtXFZLcYgxIao0vywLlrJLiUKvY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XtXFZLcYgxIao0vywLlrJLiUKvY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Last week, we have started the topic of &lt;a href="http://www.msaccesstips.com/2009/06/hiding-report-lines-conditionally.shtml"&gt;hiding Report Detail Section data lines&lt;/a&gt; and worked through a simple example as well.  But, we have not yet seen how this action affects the normal calculations on the Report, like calculating Group-wise Sub-Totals or Report Footer Totals.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;We have seen that we can do this with simple VBA Code, if we know how MS-Access works on the data &lt;b&gt;Format&lt;/b&gt;ting and &lt;b&gt;Print&lt;/b&gt;ing actions on the &lt;a href="http://www.msaccesstips.com/2007/08/reports-page-border.shtml"&gt;Report&lt;/a&gt; before it shows the results to us.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;This week we will work with a sample report to see how Group-level &lt;b&gt;Sub-Totals&lt;/b&gt; are calculated by MS-Access, when some of the group-level records or data lines are conditionally suppressed from showing on the Report with VBA Code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For this example we need three data Tables from &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office11\Samples\NorthWind.mdb&lt;/font&gt; sample Database.&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Import the following Tables into your database:&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Orders&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Order Details&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Products&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Open a new Query and display its SQL Window.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following &lt;b&gt;SQL String&lt;/b&gt; into the &lt;b&gt;SQL Editing Window&lt;/b&gt; and &lt;b&gt;Save&lt;/b&gt; the &lt;a href="http://www.msaccesstips.com/2008/02/union-query.shtml"&gt;Query&lt;/a&gt; with the Name Order_DetailsQ:&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;SELECT Orders.CustomerID,&lt;br /&gt;   [Order Details].OrderID,&lt;br /&gt;   Products.ProductName,&lt;br /&gt; [Order Details].Quantity&lt;br /&gt;FROM Orders INNER JOIN ([Order Details] INNER JOIN Products ON [Order     Details].ProductID = Products.ProductID) ON Orders.OrderID = [Order Details].OrderID&lt;br /&gt;WHERE ((([Order Details].OrderID) Between 10248 And 10300) AND ((Left([CustomerID],1)) Between &amp;quot;A&amp;quot; And &amp;quot;L&amp;quot;));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We have used conditions in the &lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Query&lt;/a&gt; to select only few records, enough to limit the number of Pages on the Report to three, so that we can check the accuracy of values appearing in Group-wise Sub-Totals and Report Footer Total easily.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Click on the Order_DetailsQ query to select it and select &lt;b&gt;Report&lt;/b&gt; from &lt;b&gt;Insert&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Report Wizard&lt;/a&gt; from the displayed list of options and click &lt;b&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select all fields from the &lt;b&gt;Available Fields&lt;/b&gt; List and move them to the &lt;b&gt;Selected Fields&lt;/b&gt; List and click &lt;b&gt;Next&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The &lt;b&gt;CustomerID&lt;/b&gt; field is already selected for Grouping Levels.  If any other Field is appearing on the Report sample View then click the &lt;b&gt;&amp;lt;&lt;/b&gt; Button to remove it and select &lt;b&gt;CustomerID&lt;/b&gt; Field from the Field List and click &lt;b&gt;&amp;gt;&lt;/b&gt; Button to use it as Group Level and click &lt;b&gt;Next&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Summary Options&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt; and put a Check Mark under the &lt;b&gt;Sum&lt;/b&gt; option for &lt;b&gt;Quantity&lt;/b&gt; Field, click &lt;b&gt;OK&lt;/b&gt; and then click &lt;b&gt;Finish&lt;/b&gt; to create the Report.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the Report with the name &lt;b&gt;Order_Details&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Open the Report in Print Preview and check the &lt;b&gt;Sub-Totals&lt;/b&gt; and &lt;b&gt;Report Footer Total&lt;/b&gt;.  The Report will look like the sample image given below.  If you have access to a &lt;b&gt;Printer&lt;/b&gt; then take a print out, it is only three pages long, so that we can compare the results when we hide the report lines with program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msaccesstips.com/uploaded_images/hidinglines2-744577.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 254px; height: 320px;" src="http://www.msaccesstips.com/uploaded_images/hidinglines2-744573.jpg" border="0" alt="Sample Report Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We are going to hide data lines of &lt;b&gt;OrderID&lt;/b&gt; Numbers &lt;b&gt;10280&lt;/b&gt; (three records) and &lt;b&gt;10297&lt;/b&gt; (two records) from Customer Groups &lt;b&gt;BERGS&lt;/b&gt; and &lt;b&gt;BLONP&lt;/b&gt; respectively. Let us see what happens to the &lt;b&gt;Sub-Totals&lt;/b&gt; and &lt;b&gt;Report Totals&lt;/b&gt; when these five lines are prevented from showing up on the Report.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the Report in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module (&lt;b&gt;View - -&gt; Code&lt;/b&gt;) of the Report.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into the Module, Save and close the Report.&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;If [OrderID] = 10280 Or [OrderID] = 10297 Then&lt;br /&gt;      Cancel = True&lt;br /&gt;Else&lt;br /&gt;      Cancel = False&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Read the earlier Article with the Title: &lt;a href="http://www.msaccesstips.com/2009/06/hiding-report-lines-conditionally.shtml"&gt;hiding-report-lines-Conditionally&lt;/a&gt; to learn how to use a &lt;b&gt;parameter table&lt;/b&gt; to add several OrderIDs to filter, instead of Constant values in the &lt;b&gt;If…Then&lt;/b&gt; statement.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the Report in Print Preview.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check the &lt;b&gt;Sub-Totals&lt;/b&gt; of CustomerIDs &lt;b&gt;BERGS&lt;/b&gt; and &lt;b&gt;BLONP&lt;/b&gt; with the Print out you have taken earlier.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Even though we have removed three entries from the first Customer and two from the second there is no change in the Group &lt;b&gt;Sub-Totals&lt;/b&gt; or &lt;b&gt;Report Footer Total&lt;/b&gt;.  The Code only prevents the report from showing the data lines on the Report but MS-Access did not exclude these entries from Summary Totals.  The Label appearing above the Summary Totals with the text &lt;b&gt;&lt;i&gt;Summary for CustomerID = BERGS (7 records)&lt;/i&gt;&lt;/b&gt; is also misleading. First thing first, we will eliminate this label before we take care of the Summary Totals.  We don&amp;#39;t want to add more lines in the Program to update this Label value also.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the Report in &lt;b&gt;Design View&lt;/b&gt; and delete the Text Box with the expression that shows the above Summary message.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Before we proceed further with corrective actions for showing Sub-Totals and Report Total I want to draw your attention to the above Code that we have used for this example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you have tried last week&amp;#39;s example you will see some difference in both VBA Codes.  Last Week we have asked MS-Access to hide the &lt;b&gt;Detail Section&lt;/b&gt; with the statement &lt;font class="colrgreen"&gt;Report.Section(acDetail).Visible = False&lt;/font&gt; during the Report &lt;b&gt;Format Event&lt;/b&gt; when the OrderIDs in the criterion are encountered. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this example we have asked MS-Access to Cancel the Format action.  As far as the output is concerned both these actions have the same result. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;You can run another experiment by running the same Code under the &lt;b&gt;Print Event&lt;/b&gt; Procedure and see what difference it makes.  I will give the Code below. You may Copy and Paste it in the Report Module overwriting the earlier Code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;If [OrderID] = 10280 Or [OrderID] = 10297 Then&lt;br /&gt;   Cancel = True&lt;br /&gt;Else&lt;br /&gt;      Cancel = False&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Open the Report in &lt;b&gt;Print Preview&lt;/b&gt; and inspect the area of the records of OrderIDs we have used in the criterion.  Even though the data lines are suppressed from appearing on the Report the empty space of those Report Lines are left on the Report.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;We will now proceed with the &lt;b&gt;Sub-Total&lt;/b&gt; and &lt;b&gt;Report Footer Total&lt;/b&gt; calculation part.  That&amp;#39;s right; we have to Calculate the Quantity Totals excluding the Values of Orders 10280 and 10297 and write it directly in the &lt;b&gt;Sub-Totals&lt;/b&gt; and &lt;b&gt;Report Footer Total&lt;/b&gt; Text Boxes.  Let us see how we do that.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open the Report in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Remove the expression &lt;font class="colrgreen"&gt;=Sum([Quantity])&lt;/font&gt; from the Text Box &lt;b&gt;Control Source&lt;/b&gt; Property in the CustomerID &lt;b&gt;Group Footer&lt;/b&gt; and in the &lt;b&gt;Report Footer&lt;/b&gt; Sections.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Group Footer &lt;b&gt;Sub-Total&lt;/b&gt; Text Box and display its &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet (&lt;b&gt;View - -&gt; Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;b&gt;SubTotal&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Similarly change the &lt;b&gt;Name&lt;/b&gt; Property Value of Page Footer Text Box to &lt;b&gt;GTotal&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into the Report Module replacing the earlier Code.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Dim x_SubTotal As Long, x_GTotal As Long&lt;br /&gt;&lt;br /&gt;Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;If [OrderID] = 10280 Or [OrderID] = 10297 Then&lt;br /&gt;    Cancel = True&lt;br /&gt;Else&lt;br /&gt;    Cancel = False&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;If PrintCount = 1 Then&lt;br /&gt;    x_SubTotal = x_SubTotal + [Quantity]&lt;br /&gt;    x_GTotal = x_GTotal + [Quantity]&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub GroupFooter0_print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;If PrintCount = 1 Then&lt;br /&gt;    [SubTotal] = x_SubTotal&lt;br /&gt;    x_SubTotal = 0&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub ReportFooter_print(Cancel As Integer, PrintCount As Integer)&lt;br /&gt;If PrintCount = 1 Then&lt;br /&gt;    [GTotal] = x_GTotal&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Save&lt;/b&gt; the Report, open it in &lt;b&gt;Print Preview&lt;/b&gt; and check whether the &lt;b&gt;Sub-Totals&lt;/b&gt; and &lt;b&gt;Report Footer Totals&lt;/b&gt; are appearing now correctly or not.&lt;/li&gt;  &lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;In the above code we have prevented the Report from showing the record lines in the &lt;b&gt;Format Event&lt;/b&gt; and the &lt;b&gt;Calculation&lt;/b&gt; is done in the &lt;b&gt;Print Event&lt;/b&gt; of the Report.  We are checking whether the &lt;b&gt;PrintCount&lt;/b&gt; parameter Value is &lt;b&gt;1&lt;/b&gt; or not, to correctly calculate the Totals.  The &lt;b&gt;Print Event&lt;/b&gt; can take place more than once if you move from a Page to an earlier Page in the &lt;b&gt;Retreat Event&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;So far everything went on well, but there is a major problem with this method and it is important that the &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;User&lt;/a&gt; must be aware of this to avoid undesirable results.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you jump directly to a page (say from page 2 to the Last Page by typing the Page Number in the Report Page control below in Preview) then our line by line Calculation on every Page fails and the Report Footer Totals will be wrong.  So, if the User is not aware of this issue and jumps through the Report Pages in Print Preview, before printing the Report, then we are in soup. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To work around this problem we can use any of the following methods:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Use &lt;b&gt;Custom Menus&lt;/b&gt; and &lt;b&gt;Tool Bars&lt;/b&gt; in your application and use separate options for &lt;b&gt;Printing&lt;/b&gt; and &lt;b&gt;Previewing&lt;/b&gt; the Report.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Refer the following Articles to learn more about Custom Menus and Toolbars.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/calendar-and-toolbars.shtml"&gt;Calendar and Toolbars&lt;/a&gt;  &lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml "&gt;Custom Menus and Tool Bars&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars2.shtml"&gt;Custom Menus and Tool Bars-2&lt;/a&gt;  &lt;br /&gt;&lt;br /&gt;I recommend the above method rather than the second one given below.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Disable &lt;b&gt;Print…&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Buttons&lt;/a&gt; from &lt;b&gt;File&lt;/b&gt; Menu and from Report &lt;b&gt;Preview&lt;/b&gt; Menu while previewing this particular Report and enable them again when Preview is closed.  To do this add the following Code into the Module of the Report:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Sub Report_Close()&lt;br /&gt;   CommandBars(&amp;quot;File&amp;quot;).Controls(&amp;quot;Print...&amp;quot;).Enabled = True&lt;br /&gt;   CommandBars(&amp;quot;Print Preview&amp;quot;).Controls(&amp;quot;Print&amp;quot;).Enabled = True&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Report_Open(Cancel As Integer)&lt;br /&gt;   CommandBars(&amp;quot;File&amp;quot;).Controls(&amp;quot;Print...&amp;quot;).Enabled = False&lt;br /&gt;   CommandBars(&amp;quot;Print Preview&amp;quot;).Controls(&amp;quot;Print&amp;quot;).Enabled = False&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you are using MS-Access2000 then use the same Control name &lt;b&gt;Print…&lt;/b&gt; in both lines of Code.  The above code is written for MSAccess2003.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To send the Report directly to the Printer you may use either a Print Macro or the following line of code to run from a &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; Click Event or from a &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-menu-design.shtml"&gt;List Box &lt;/a&gt; based Menu Option.&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;DoCmd.OpenReport &amp;quot;myReport&amp;quot;, acViewNormal&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;To be on the safest side use this method on Reports having only 2 pages.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Next we will examine how to hide Group level information like Group-Header, Detail and Group-Footer Sections with Code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/07/hiding-report-lines-conditionally-2.shtml&amp;amp;title=Hiding +Report+Lines+Conditionally-2"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/03/positioning-pop-up-forms.shtml"&gt;Positioning POPUP Forms&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Synchronized Floating Popup Form&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml"&gt;Forms and Custom Properties&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml"&gt;Control Tip Text and Time Delay&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;External Files List in Hyperlinks&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-6126014601463320436?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=r4QaSLiju-0:l69dwdbaHuo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=r4QaSLiju-0:l69dwdbaHuo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=r4QaSLiju-0:l69dwdbaHuo:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=r4QaSLiju-0:l69dwdbaHuo:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=r4QaSLiju-0:l69dwdbaHuo:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/r4QaSLiju-0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/r4QaSLiju-0/hiding-report-lines-conditionally-2.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/07/hiding-report-lines-conditionally-2.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-4668831071149112519</guid><pubDate>Thu, 25 Jun 2009 20:34:00 +0000</pubDate><atom:updated>2009-07-03T13:27:44.788+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess reporttricks</category><title>Hiding Report Lines Conditionally</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/L9bP3bqjvrmSQXgw6jHWL74puDo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L9bP3bqjvrmSQXgw6jHWL74puDo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/L9bP3bqjvrmSQXgw6jHWL74puDo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L9bP3bqjvrmSQXgw6jHWL74puDo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Hiding Report lines or Report Sections conditionally at run time may not be an every day requirement.   But, it is interesting to know how to do it, if it becomes necessary, with the help of Programs.  One thing I like very much about MS-Access Report is its ability to write programs on the Report itself, especially for highlighting very critical information on the Report so that the attention of Users can be drawn to specific information on it.  You can see an interesting and useful example in one of the earlier Posts with the Title: &lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Highlighting Reports&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To suppress something from appearing on the &lt;a href="http://www.msaccesstips.com/2007/08/reports-page-border.shtml"&gt;Report&lt;/a&gt; we normally think about using a &lt;a href="http://www.msaccesstips.com/2008/02/percentage-on-total-query.shtml"&gt;Query&lt;/a&gt; to filter out unwanted items from Source Data before Previewing or Printing the Report.  Frankly, Query is the best method compared to what I am trying to show you here.  To get the same result on the Report without filtering the source data we have to play around with few tricks (after all, this is all about Tips &amp; Tricks, right?). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you really enjoy working with MS-Access programs then read on.  As far as the program code is concerned there is nothing complicated to deal with, all we need is few lines of simple code and even a &lt;a href="http://www.msaccesstips.com/2008/06/working-with-chart-object-in-vba.shtml"&gt;VBA&lt;/a&gt; beginner can easily understand them. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It is interesting to do something different, which not only kills the boredom of doing the same thing again and again but also gives you better insight in doing things better next time. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will create a sample Report quickly to try out this Trick. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Import &lt;b&gt;Orders&lt;/b&gt; and &lt;b&gt;Employees&lt;/b&gt; Tables from &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office11\samples\Northwind.mdb&lt;/font&gt; sample Database.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;We will not be using &lt;b&gt;Employees&lt;/b&gt; Table directly on the Report.  Without the Employees Table in the Database only &lt;b&gt;EmployeeID&lt;/b&gt;s will be displayed on the Report when the Report is designed with Orders Table. There is a reference to the Employees Table (&lt;a href="http://www.msaccesstips.com/2008/03/refresh-dependant-combo-box-contents.shtml"&gt;Combo Box&lt;/a&gt; using Employees Table) in the &lt;b&gt;EmployeeID&lt;/b&gt; Field in &lt;b&gt;Orders&lt;/b&gt; Table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Orders&lt;/b&gt; Table and select Report from &lt;b&gt;Insert&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select Report Wizard from the displayed list and click &lt;b&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the following Data Fields from the &lt;b&gt;Available Fields&lt;/b&gt; List and move them one by one to the &lt;b&gt;Selected Fields&lt;/b&gt; List:&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;OrderID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;CustomerID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;EmployeeID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;OrderDate&lt;/li&gt;&lt;br /&gt;&lt;li&gt;RequiredDate&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Click &lt;b&gt;Next&lt;/b&gt; and select &lt;b&gt;CustomerID&lt;/b&gt; as &lt;b&gt;Grouping Level&lt;/b&gt; and move it to the right. Click &lt;b&gt;Next&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;OrderID&lt;/b&gt; for &lt;b&gt;Sorting&lt;/b&gt; in the first Sort Control and Click &lt;b&gt;Finish&lt;/b&gt; to create the sample Report. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;An image of the sample Report is given below: &lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msaccesstips.com/uploaded_images/hidelines-727031.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 293px; height: 320px;" src="http://www.msaccesstips.com/uploaded_images/hidelines-727028.jpg" border="0" alt="Sample Report Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;a href="http://www.msaccesstips.com/2007/10/dynamic-report.shtml"&gt;Report&lt;/a&gt; in Print Preview and check the Order Numbers appearing under the first three Customer Groups on the Report. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;We will attempt to hide three different &lt;b&gt;Orders&lt;/b&gt; ( OrderIDs &lt;b&gt;10702&lt;/b&gt;, &lt;b&gt;10625 &amp; 10573&lt;/b&gt; from &lt;b&gt;ALFKI, ANATR &amp; ANTON&lt;/b&gt; Customer&amp;#39;s List respectively) from appearing on the Report with the following simple lines of Code: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;If [OrderID] = 10702 Or [OrderID] = 10625 Or [OrderID] = 10573 Then&lt;br /&gt;      Report.Section(acDetail).Visible = False&lt;br /&gt;Else&lt;br /&gt;   Report.Section(acDetail).Visible = True&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you look at the above Code you can see that the Code runs under the &lt;b&gt;On Format&lt;/b&gt; Event Procedure on &lt;b&gt;Detail Section&lt;/b&gt; of the Report. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open your Report in Design View and display the Code Module (&lt;b&gt;View - -&gt;Code&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the above Code into the Report Module.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Close and Return to Microsoft Office Access&lt;/b&gt; from &lt;b&gt;File&lt;/b&gt; Menu to close the VBA Window and return to the Design View of the Report.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Or you can press &lt;b&gt;Alt+F11&lt;/b&gt; to Toggle between Database Window and VBA Window.  Visit the Page &lt;a href="http://www.msaccesstips.com/2007/12/keyboard-shortcuts.shtml"&gt;Keyboard Shortcuts&lt;/a&gt; to learn more about Keyboard Shortcuts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Detail Section&lt;/b&gt; of the Report and display the Property Sheet (&lt;b&gt;View - -&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check the &lt;b&gt;On Format&lt;/b&gt; Event Property and you can see that the entry &lt;b&gt; [EventProcedure] &lt;/b&gt; is appearing there indicating that the Code that we have pasted Runs on the &lt;b&gt;Format Event&lt;/b&gt; of the Report.&lt;/li&gt; &lt;br /&gt;&lt;br /&gt;There are two more &lt;b&gt;Events&lt;/b&gt; associated with the Report&amp;#39;s Printing or Previewing action; &lt;b&gt;Print&lt;/b&gt; Event and &lt;b&gt;Retreat&lt;/b&gt; Event. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MS-Access makes two passes over the Report before it is actually displayed or Printed.  First, the &lt;b&gt;Format&lt;/b&gt; pass lays out each &lt;b&gt;Report Section&lt;/b&gt; contents doing calculations, if needed for Summary information (we will deal with this in the forthcoming Articles).  The &lt;b&gt;Print&lt;/b&gt; action takes place in the second pass, which prints the contents on the Report before Previewing or sending to Printer. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Retreat&lt;/b&gt; Event takes place when you move the Page Preview to an earlier Page.  At this time the &lt;b&gt;Format&lt;/b&gt; action takes place a second time for the &lt;b&gt;Retreated&lt;/b&gt; Page and the &lt;b&gt;FormatCount&lt;/b&gt; Parameter value in the &lt;font class="colrgreen"&gt;Private Sub Detail_Format(Cancel As Integer, &lt;b&gt;FormatCount As Integer&lt;/b&gt;)&lt;/font&gt; is incremented by one.  This has some negative impact if we are performing some calculations in the above Procedure.  This aspect we will examine in the forthcoming Articles. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Save the Report and open it in Print Preview.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check whether the Report Lines associated with &lt;b&gt;OrderID&lt;/b&gt;s 10702, 10625 &amp; 10573 are still appearing on the Report or not.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;We were using Constant values for &lt;b&gt;OrderID&lt;/b&gt;s in the Program to check and suppress the Report lines from appearing on the Report.  We cannot expect the User to open the Report in Design View and change the Program every time to change the OrderIDs, if it become necessary,  before printing the Report.  Besides, there may be more than two or three Orders to hide this way.  We must provide a much simpler method to the User to input the OrderIDs as parameters to the Program and Run the Report based on that. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will create a parameter table to key in OrderIDs, read them in the program and compare with the Report OrderIDs and skip those lines on the Report for matching cases. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a Table with the name &lt;b&gt;OrderParam&lt;/b&gt; with a single Field with the name &lt;b&gt;OID&lt;/b&gt; with Data Type &lt;b&gt;Number&lt;/b&gt; and Field Size &lt;b&gt;Long Integer&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Primary Key&lt;/b&gt; from &lt;b&gt;Edit&lt;/b&gt; Menu to define this field as a Primary Key Field.  This will prevent duplicate values going into the Parameter Table and makes it easier to cross-check OrderIDs from Report.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the Table and open it in Data Sheet View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Key in the OrderIDs 10702, 10625 and 10573 (or any other OrderIDs you would like to hide) in the &lt;b&gt;OrderParam&lt;/b&gt; Table.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;You may even design a Continuous &lt;a href="http://www.msaccesstips.com/2007/12/progress-meter.shtml"&gt;Form&lt;/a&gt; for the Table and create a &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Button&lt;/a&gt; at the Footer Section of the Form with &lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;HyperLinks&lt;/a&gt; to the &lt;b&gt;Orders&lt;/b&gt; Report so that the &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;User&lt;/a&gt; can launch the Report from the Parameter Screen itself.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code in the Report&amp;#39;s Code Module replacing the earlier Code:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Dim cdb As Database, rst As Recordset&lt;br /&gt;&lt;br /&gt;Private Sub Report_Open(Cancel As Integer)&lt;br /&gt;     Set cdb = CurrentDb&lt;br /&gt;    Set rst = cdb.OpenRecordset(&amp;quot;OrderParam&amp;quot;)&lt;br /&gt;    rst.Index = &amp;quot;PrimaryKey&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)&lt;br /&gt;rst.Seek &amp;quot;=&amp;quot;, [OrderID]&lt;br /&gt;If Not rst.NoMatch Then&lt;br /&gt;    Report.Section(acDetail).Visible = False&lt;br /&gt;Else&lt;br /&gt;    Report.Section(acDetail).Visible = True&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Report_Close()&lt;br /&gt;   rst.Close&lt;br /&gt;   Set rst = Nothing&lt;br /&gt;   Set cdb = Nothing&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Save the Report with the new Code and open it in Print Preview.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Look for the OrderIDs given in the &lt;b&gt;OrderParam&lt;/b&gt; Table to check whether they are really suppressed from the Report or not.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Let us examine what we did in the above Code. &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;We have declared the &lt;b&gt;Database&lt;/b&gt; and &lt;b&gt;Recordset&lt;/b&gt; Objects at Global level of the Report Module so that we can refer to these objects in all other Sub-Routines.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Opening the &lt;b&gt;OrderParam&lt;/b&gt; Table and activate the &lt;b&gt;PrimaryKey Index&lt;/b&gt; on the Report&amp;#39;s &lt;b&gt;Open Event Procedure&lt;/b&gt; and keep it memory.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;We cross-check each &lt;b&gt;OrderID&lt;/b&gt; with the &lt;b&gt;OrderParam&lt;/b&gt; Table contents on the Report&amp;#39;s Detail Section &lt;b&gt;Format Event Procedure&lt;/b&gt; and hide the Report line for the OrderId that matches with the &lt;b&gt;OrderParam&lt;/b&gt; value. This process continues till it reaches the end of the Report.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;The &lt;b&gt;OrderParam&lt;/b&gt; Recordset is closed in the &lt;b&gt;Close Event Procedure&lt;/b&gt; of the Report.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Since, the checking process need referencing an external table for each record of the Report Source Data  there will be slight delay before the Previewing or Printing action takes place. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next we will explore how this method works with Customer Level Summary Totals in the &lt;b&gt;Customer Footer&lt;/b&gt; Section of the Report.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/06/hiding-report-lines-conditionally.shtml&amp;amp;title=Hiding+Report+Lines+Conditionally"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Synchronized Floating Popup Form&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml"&gt;Forms and Custom Properties&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml"&gt;Control Tip Text and Time Delay&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;External Files List in Hyperlinks&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml"&gt;Combo Box Column Values&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-4668831071149112519?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=7GcfFkAdC1Y:bRwyltoB0Ks:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=7GcfFkAdC1Y:bRwyltoB0Ks:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=7GcfFkAdC1Y:bRwyltoB0Ks:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=7GcfFkAdC1Y:bRwyltoB0Ks:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=7GcfFkAdC1Y:bRwyltoB0Ks:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/7GcfFkAdC1Y" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/7GcfFkAdC1Y/hiding-report-lines-conditionally.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/06/hiding-report-lines-conditionally.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-3488131855306209069</guid><pubDate>Fri, 19 Jun 2009 08:33:00 +0000</pubDate><atom:updated>2009-07-09T12:34:03.073+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess reports</category><title>Network And Print Page Setup-3</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aNPx2CucAbMXowutTTg1LSORozY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aNPx2CucAbMXowutTTg1LSORozY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aNPx2CucAbMXowutTTg1LSORozY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aNPx2CucAbMXowutTTg1LSORozY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Shared MS-Access Reports are normally designed for a particular Printer on the &lt;a href="http://www.msaccesstips.com/2008/03/sending-alerts-to-workstations.shtml"&gt;Network&lt;/a&gt;. When Users attempt to print this Report on a different Printer the Report will change to the &lt;b&gt;default Page Settings&lt;/b&gt; of that Printer, like &lt;b&gt;Paper Size, Page Orientation&lt;/b&gt; and others and the Report may not print correctly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have familiarized how to change &lt;b&gt;Page Setup&lt;/b&gt; Values (&lt;a href="http://www.msaccesstips.com/2009/06/network-and-report-page-setup.shtml"&gt;Paper Size, Page Orientation&lt;/a&gt; and &lt;a href="http://www.msaccesstips.com/2009/06/network-and-print-page-setup-2.shtml"&gt;Margin Settings&lt;/a&gt;) of Reports through VBA Programs before printing the Report on Network based Printers in the earlier Posts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This subject is not complete unless we touch the topic of &lt;b&gt;Columns&lt;/b&gt; Setting changes (&lt;b&gt;File - -&gt; Page Setup - -&gt; Columns&lt;/b&gt;) through Program for multi-column Reports.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Columns&lt;/b&gt; Tab values of &lt;b&gt;Page Setup&lt;/b&gt; Dialog Control are also modified through the &lt;b&gt;PrtMip Property Values&lt;/b&gt; of Report. If you have gone through the earlier Post on &lt;b&gt;Margin Settings&lt;/b&gt; then you have already created the User Defined data types to copy &lt;b&gt;PrtMip Property Values&lt;/b&gt; into memory for modification.  In that case you need only a new Sub-Routine to modify the Report &lt;b&gt;Column&lt;/b&gt; settings of a multi-column Report and open it in Print Preview.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For the benefit of the Readers who have landed on this Page directly; I will reproduce the first part of the Code (declaring two User-defined data types segment) below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Open the VBA Editing window (&lt;b&gt;Alt+F11&lt;/b&gt;); insert a new Standard Module (Global Module) - (&lt;b&gt;Insert - -&gt; Module&lt;/b&gt;), copy and paste the following &lt;b&gt;Code&lt;/b&gt; (from both Code windows) into the Module immediately below the global declaration line &lt;b&gt;Option Compare Database&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Those who have already copied the first part for &lt;b&gt;Margin Setting&lt;/b&gt; example take the code from the second Code window and paste it into the same Module where you have placed the data type declarations for &lt;b&gt;PrtMip Property&lt;/b&gt; earlier. You can paste the Code into a different Global Module, if you prefer to do so.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Type str_PRTMIP&lt;br /&gt;    strRGB As String * 28&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Private Type type_PRTMIP&lt;br /&gt;    xLeftMargin As Long&lt;br /&gt;    yTopMargin As Long&lt;br /&gt;    xRightMargin As Long&lt;br /&gt;    yBotMargin As Long&lt;br /&gt;    fDataOnly As Long&lt;br /&gt;    xWidth As Long&lt;br /&gt;    yHeight As Long&lt;br /&gt;    fDefaultSize As Long&lt;br /&gt;    cxColumns As Long&lt;br /&gt;    yColumnSpacing As Long&lt;br /&gt;    xRowSpacing As Long&lt;br /&gt;    rItemLayout As Long&lt;br /&gt;    fFastPrint As Long&lt;br /&gt;    fDatasheet As Long&lt;br /&gt;End Type&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Sub PageColumns(ByVal strName As String)&lt;br /&gt;&lt;br /&gt;    Dim PrtMipString As str_PRTMIP&lt;br /&gt;    Dim PM As type_PRTMIP&lt;br /&gt;    Dim rpt As Report&lt;br /&gt;    Const PM_HORIZONTALCOLS = 1953&lt;br /&gt;    Const PM_VERTICALCOLS = 1954&lt;br /&gt;    Const TWIPS = 1440&lt;br /&gt;    &lt;br /&gt;    ' Open the report.&lt;br /&gt;    DoCmd.OpenReport strName, acDesign&lt;br /&gt;    Set rpt = Reports(strName)&lt;br /&gt;    PrtMipString.strRGB = rpt.PrtMip&lt;br /&gt;    LSet PM = PrtMipString&lt;br /&gt;    &lt;br /&gt;    ' Create two columns.&lt;br /&gt;    PM.cxColumns = 2&lt;br /&gt;    &lt;br /&gt;    ' Set 0.25 inch between rows.&lt;br /&gt;    PM.xRowSpacing = 0.25 * TWIPS&lt;br /&gt;    &lt;br /&gt;    ' Set 0.5 inch between columns.&lt;br /&gt;    PM.yColumnSpacing = 0.5 * TWIPS&lt;br /&gt;    PM.rItemLayout = PM_VERTICALCOLS&lt;br /&gt;    &lt;br /&gt;    ' Update property.&lt;br /&gt;    LSet PrtMipString = PM&lt;br /&gt;    rpt.PrtMip = PrtMipString.strRGB&lt;br /&gt;    &lt;br /&gt;    DoCmd.Close acReport, strName, acSaveYes&lt;br /&gt;    DoCmd.OpenReport strName, acViewPreview&lt;br /&gt;    &lt;br /&gt;    Set rpt = Nothing&lt;br /&gt;    &lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Next step is to create a multi-column sample &lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Report&lt;/a&gt; to test our Program.  We can design a Report for &lt;a href="http://www.msaccesstips.com/2007/10/ms-access-and-mail-merge.shtml"&gt;Address Labels&lt;/a&gt; with the Imported &lt;b&gt;Employees&lt;/b&gt; Table from MS-Access sample database &lt;b&gt;Northwind.mdb&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Import (&lt;b&gt;File - -&gt;Get External Data - - &gt;Import&lt;/b&gt;) the &lt;b&gt;Employees&lt;/b&gt; Table from &lt;font class="colrgreen"&gt; C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb&lt;/font&gt; Sample Database.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Employees&lt;/b&gt; Table and select &lt;b&gt;Report&lt;/b&gt; from &lt;b&gt;Insert&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Design View&lt;/b&gt; from the displayed list of Options.&lt;/li&gt;  &lt;br /&gt;&lt;br /&gt;We are going to design Address Labels manually.  If you prefer the &lt;b&gt;Label Wizard&lt;/b&gt; in the displayed list you may use that instead.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Remove the &lt;b&gt;check mark&lt;/b&gt; from &lt;b&gt;Page Header/Footer&lt;/b&gt; Option of &lt;b&gt;View&lt;/b&gt; Menu to remove the Page Header/Footer Sections from the Report Design.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design a sample Label in the &lt;b&gt;Detail Section&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Report&lt;/a&gt; as shown in the Image given below.&lt;/li&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msaccesstips.com/uploaded_images/columndesign1-734086.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 233px; height: 320px;" src="http://www.msaccesstips.com/uploaded_images/columndesign1-734082.jpg" border="0" alt="Report with Column Design" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create four &lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Boxes&lt;/a&gt; about the size of &lt;b&gt;2.75 Inches long&lt;/b&gt; and &lt;b&gt;0.25 Inches high&lt;/b&gt; each and arrange them close by as shown on the design.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet of each Text Box (&lt;b&gt;View - -&gt;Properties&lt;/b&gt;) and write the expressions in the top and third Text Boxes and insert the Field names &lt;b&gt;Address&lt;/b&gt; and &lt;b&gt;Country&lt;/b&gt; in second and fourth Text Boxes respectively.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click outside the Text boxes and drag the mouse over them to select all the four Text Boxes together.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the Text Boxes (&lt;b&gt;View - -&gt; Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Border Color&lt;/b&gt; Property value to &lt;b&gt;0&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box from &lt;b&gt;File&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars2.shtml"&gt;Menu&lt;/a&gt; and select &lt;b&gt;Columns&lt;/b&gt; Tab.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the values on the controls as shown in the image above.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Look carefully at the settings in the &lt;b&gt;Columns&lt;/b&gt; Tab to understand what would be the result of those values, when the Labels are printed? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Labels will be printed in two Columns and the spacing between both Columns across will be half an Inch wide.  The vertical spacing between labels will be quarter of an Inch. The &lt;b&gt;Width&lt;/b&gt; of a Label is &lt;b&gt;3.25 Inches&lt;/b&gt; and &lt;b&gt;1.4 Inches high&lt;/b&gt;, including the blank spaces around the text boxes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Column Layout (&lt;b&gt;Across, then Down&lt;/b&gt;) setting is very important to note because the arrangement of Labels on the Report depends on it.  The current settings translates into arranging the labels across then down order rather than printing the labels at the left column fully then flow out into the second column later (&lt;b&gt;Down, then Across&lt;/b&gt;). We prefer the second option, which we will change through our Program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You may set the &lt;b&gt;Margin Values&lt;/b&gt; to &lt;b&gt;0.5 Inches&lt;/b&gt; on all four sides on the &lt;b&gt;Margins&lt;/b&gt; Tab.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;A4 Paper Size&lt;/b&gt; and &lt;b&gt;Orientation&lt;/b&gt; to &lt;b&gt;Portrait&lt;/b&gt; on the &lt;b&gt;Page&lt;/b&gt; Tab and close the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2009/04/filter-by-character-and-sort.shtml"&gt;Sorting&lt;/a&gt; and Grouping&lt;/b&gt; Toolbar Button above.  You can find this icon at the top right end (next to the Tool Box Button icon) on the above image.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;FirstName&lt;/b&gt; in the &lt;b&gt;Field/Expressions&lt;/b&gt; Column and &lt;b&gt;Ascending&lt;/b&gt; in the &lt;b&gt;Sort Order&lt;/b&gt; Column.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the Report with the name &lt;b&gt;MyLabels&lt;/b&gt; or any other name you prefer.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;a href="http://www.msaccesstips.com/2007/10/dynamic-report.shtml"&gt;Report&lt;/a&gt; in Print Preview and check the arrangement of Labels and values in them. The Employee Names were sorted in &lt;b&gt;First Name&lt;/b&gt; Order on the Report. The Label arrangement is now &lt;b&gt;Across, then Down&lt;/b&gt; order.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Close the Report Preview and open it in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box and select the &lt;b&gt;Columns&lt;/b&gt; Tab.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Row Spacing&lt;/b&gt; Value to &lt;b&gt;0 Inch&lt;/b&gt; and the &lt;b&gt;Column Spacing&lt;/b&gt; value to &lt;b&gt;0.1 Inch&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Leave the &lt;b&gt;Column Layout&lt;/b&gt; Value (&lt;b&gt;Across, then Down&lt;/b&gt;) setting as it is.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Column Layout&lt;/b&gt; Value and the &lt;b&gt;Column &amp;amp; Row Spacing&lt;/b&gt; Values we will change through Program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You can run the Program &lt;b&gt;PageColumns()&lt;/b&gt; directly from the Debug Window (Immediate Window) for testing. Press &lt;b&gt;Alt+F11&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/12/keyboard-shortcuts.shtml"&gt;Keyboard Shortcut&lt;/a&gt; to display the VBA Editing Window and press &lt;b&gt;Ctrl+G&lt;/b&gt; to bring up the Debug window.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Type &lt;b&gt;PageColumns &amp;quot;MyLabels&amp;quot;&lt;/b&gt; in the Debug Window and press &lt;b&gt;Enter Key&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Through the &lt;b&gt;PageColumns()&lt;/b&gt; Program we have now changed the Report &lt;b&gt;Column Layout&lt;/b&gt; to &lt;b&gt;Down, then Across&lt;/b&gt; and the &lt;b&gt;Column, Row spacing&lt;/b&gt; of Labels to the original settings we have initially specified on the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can run the Program through a &lt;b&gt;Button Click Event Procedure&lt;/b&gt; from your &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Main Switchboard&lt;/a&gt; by adding the following lines of sample Code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;Private Sub cmdPreview_Click()&lt;br /&gt; PageColumns &amp;quot;YourReportName&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can call &lt;b&gt;PageColumns()&lt;/b&gt; Program and pass the &lt;a href="http://www.msaccesstips.com/2007/08/reports-page-border.shtml"&gt;Report&lt;/a&gt; Name as parameter when the User attempts to print Address Labels.  This will ensure that the Address Labels are printed with correct settings on any Printer on the Network.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NB:&lt;/b&gt; &lt;i&gt;The &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;User&lt;/a&gt; must select the printer (if she has more than one Printer installed on her machine) and set it up as &lt;b&gt;Default Printer&lt;/b&gt; before attempting to print the Report.&lt;/i&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/06/network-and-print-page-setup-3.shtml&amp;amp;title=Network+and+Print+Page+Setup-3"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml"&gt;Forms and Custom Properties&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml"&gt;Control Tip Text and Time Delay&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;External Files List in Hyperlinks&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml"&gt;Combo Box Column Values&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml"&gt;Drill-Down Inquiry Screen-2&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-3488131855306209069?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cvKsPkZSbQg:7YV3MsJiSew:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cvKsPkZSbQg:7YV3MsJiSew:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cvKsPkZSbQg:7YV3MsJiSew:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cvKsPkZSbQg:7YV3MsJiSew:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cvKsPkZSbQg:7YV3MsJiSew:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/cvKsPkZSbQg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/cvKsPkZSbQg/network-and-print-page-setup-3.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/06/network-and-print-page-setup-3.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-6422237557609454019</guid><pubDate>Fri, 12 Jun 2009 13:06:00 +0000</pubDate><atom:updated>2009-06-12T18:58:57.042+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess reports</category><title>Network And Print Page Setup-2</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/j5x_5CD1Vr_KHLzaDaro293N4Cw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j5x_5CD1Vr_KHLzaDaro293N4Cw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/j5x_5CD1Vr_KHLzaDaro293N4Cw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j5x_5CD1Vr_KHLzaDaro293N4Cw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We have seen in the &lt;a href="http://www.msaccesstips.com/2009/06/network-and-report-page-setup.shtml"&gt;earlier Article&lt;/a&gt; how to change &lt;b&gt;Paper Size&lt;/b&gt; and &lt;b&gt;Page Orientation&lt;/b&gt; of MS-Access &lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;Reports&lt;/a&gt; automatically through program for any Printer on the Network.  We have copied &lt;b&gt;PrtDevMode Property&lt;/b&gt; Values into Memory; modified them to match the &lt;b&gt;Paper Size&lt;/b&gt; and &lt;b&gt;Page Orientation&lt;/b&gt; of the Report and updated them back into the &lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Report&lt;/a&gt; Page Settings before printing it on the default Printer installed on the &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;User&lt;/a&gt;'s Machine.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We are going to perform a similar exercise to change the &lt;b&gt;Margin Settings&lt;/b&gt; of MS-Access Report through program. This time we have to work with &lt;b&gt;PrtMip Property&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2007/08/reports-page-border.shtml"&gt;Report&lt;/a&gt; to change the Margin Values.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The procedure is almost same as of the previous example.  The steps taken in the Program is as follows:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Open the Report in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy the &lt;b&gt;PrtMip Property&lt;/b&gt; Values of the Report into a &lt;b&gt;28 Bytes&lt;/b&gt; long String Variable and move it into a redefined structured data area for modification.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the required Margin Values in Memory.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Update them back into the Report’s &lt;b&gt;PrtMip Property&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the Report with the changes and open it in Print Preview.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;So let us start.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open one of your Databases with Reports in it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Visual Basic Editing Window (&lt;b&gt;Alt+Fll&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Insert (&lt;b&gt;Insert - - &gt; Module&lt;/b&gt;) a new Standard Module (Global Module).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the following Code into the new Module and save it.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Type str_PRTMIP&lt;br /&gt;    strRGB As String * 28&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Private Type type_PRTMIP&lt;br /&gt;    xLeftMargin As Long&lt;br /&gt;    yTopMargin As Long&lt;br /&gt;    xRightMargin As Long&lt;br /&gt;    yBotMargin As Long&lt;br /&gt;    fDataOnly As Long&lt;br /&gt;    xWidth As Long&lt;br /&gt;    yHeight As Long&lt;br /&gt;    fDefaultSize As Long&lt;br /&gt;    cxColumns As Long&lt;br /&gt;    yColumnSpacing As Long&lt;br /&gt;    xRowSpacing As Long&lt;br /&gt;    rItemLayout As Long&lt;br /&gt;    fFastPrint As Long&lt;br /&gt;    fDatasheet As Long&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Public Sub SetMargins(ByVal strName As String)&lt;br /&gt;&lt;br /&gt;    Dim PrtMipString As str_PRTMIP&lt;br /&gt;    Dim PM As type_PRTMIP&lt;br /&gt;    Dim rpt As Report&lt;br /&gt;    Const TWIPS As Long = 1440&lt;br /&gt;    ' Open the report.&lt;br /&gt;    DoCmd.OpenReport strName, acDesign&lt;br /&gt;    Set rpt = Reports(strName)&lt;br /&gt;    PrtMipString.strRGB = rpt.PrtMip&lt;br /&gt;    LSet PM = PrtMipString&lt;br /&gt;    &lt;br /&gt;    ' Set margins.&lt;br /&gt;    PM.xLeftMargin = 0.75 * TWIPS&lt;br /&gt;    PM.yTopMargin = 0.5 * TWIPS&lt;br /&gt;    PM.xRightMargin = 0.5 * TWIPS&lt;br /&gt;    PM.yBotMargin = 0.5 * TWIPS&lt;br /&gt;    &lt;br /&gt;    ' Update property.&lt;br /&gt;    LSet PrtMipString = PM&lt;br /&gt;    rpt.PrtMip = PrtMipString.strRGB&lt;br /&gt;    &lt;br /&gt;    DoCmd.Close acReport, strName, acSaveYes&lt;br /&gt;    DoCmd.OpenReport strName, acViewPreview&lt;br /&gt;    &lt;br /&gt;    Set rpt = Nothing&lt;br /&gt;    &lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open one of your existing &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;Reports&lt;/a&gt; in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;File - -&gt;Page Setup- - &gt; Margins&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change all four sides (Left, Right, Top and Bottom) of the Margin settings to &lt;b&gt;1 Inch&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save and Close the Report.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Main Switchboard &lt;/a&gt;Form of your Application or create a new Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a new &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button &lt;/a&gt;on the Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;While the &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button &lt;/a&gt;is in selected state, display the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet (&lt;b&gt;View - -&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;b&gt;cmdPreview&lt;/b&gt; and change the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Print Preview&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the &lt;a href="http://www.msaccesstips.com/2007/05/opening-access-forms.shtml"&gt;Form &lt;/a&gt;(&lt;b&gt;View - -&gt; Code&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the following lines into the &lt;b&gt;Code Module&lt;/b&gt; of the Form.&lt;/li&gt;&lt;br /&gt;&lt;pre class="altl"&gt;&lt;br /&gt; Private Sub cmdPreview_Click()&lt;br /&gt;  SetMargins &amp;quot;MyReport&amp;quot;&lt;br /&gt; End Sub&lt;br /&gt; &lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Replace the name &lt;b&gt;MyReport&lt;/b&gt; with your own Report Name.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save and close the &lt;a href="http://www.msaccesstips.com/2007/05/open-forms-with-hyperlinks-in-listbox.shtml"&gt;Form&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the Form in normal view and Click on the &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button &lt;/a&gt;to run the Program and change all four margins of the Report to new values and to open the Report in Print Preview.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Close the Report and open it again in Design View and check whether the margin settings have been really changed through program or not.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;i&gt;If any value is less than the allowable range, based on the printer driver settings, the printer may fix it to the allowable range automatically. In that case you may find some value is greater than what you have specified. &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can do a sample run of the Program by typing &lt;b&gt;SetMargins &amp;quot;YourReportName&amp;quot;&lt;/b&gt; in the Debug Window directly, without the use of &lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Form&lt;/a&gt; or &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Button&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can run this Program from within the earlier &lt;b&gt;PaperAndOrient()&lt;/b&gt; Program to change the &lt;b&gt;Margins&lt;/b&gt; also along with the &lt;b&gt;Paper Size&lt;/b&gt; and &lt;b&gt;Page Orientation&lt;/b&gt;. All the three set of values can be changed by calling the &lt;b&gt;PaperAndOrient()&lt;/b&gt; Program alone.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The modified &lt;b&gt;PaperAndOrient()&lt;/b&gt; Program is given below:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Sub PaperAndOrient(ByVal strName As String)&lt;br /&gt;    Const DM_PORTRAIT = 1&lt;br /&gt;    Const DM_LANDSCAPE = 2&lt;br /&gt;    Const DM_PAPERSIZE = 9&lt;br /&gt;    Dim DevString As str_DEVMODE&lt;br /&gt;    Dim DM As type_DEVMODE&lt;br /&gt;    Dim strDevModeExtra As String&lt;br /&gt;    Dim rpt As Report&lt;br /&gt;    &lt;br /&gt;    ' Opens report in Design view.&lt;br /&gt;    DoCmd.OpenReport strName, acDesign&lt;br /&gt;    Set rpt = Reports(strName)&lt;br /&gt;    &lt;br /&gt;    If Not IsNull(rpt.PrtDevMode) Then&lt;br /&gt;        strDevModeExtra = rpt.PrtDevMode&lt;br /&gt;        DevString.RGB = strDevModeExtra&lt;br /&gt;        LSet DM = DevString&lt;br /&gt;        DM.lngFields = DM.lngFields Or DM.intOrientation&lt;br /&gt;&lt;br /&gt;        ' Initialize fields.&lt;br /&gt;        DM.intPaperSize = DM_PAPERSIZE&lt;br /&gt;        If DM.intOrientation = DM_PORTRAIT Then&lt;br /&gt;            DM.intOrientation = DM_LANDSCAPE&lt;br /&gt;        End If&lt;br /&gt;        &lt;br /&gt;        ' Update property.&lt;br /&gt;        LSet DevString = DM&lt;br /&gt;        Mid(strDevModeExtra, 1, 94) = DevString.RGB&lt;br /&gt;        rpt.PrtDevMode = strDevModeExtra&lt;br /&gt;    End If&lt;br /&gt;    SetMargins strName&lt;br /&gt;    DoCmd.Close acReport, strName, acSaveYes&lt;br /&gt;    DoCmd.OpenReport strName, acViewPreview&lt;br /&gt;    Set rpt = Nothing&lt;br /&gt;    &lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Sub SetMargins(ByVal strName As String)&lt;br /&gt;&lt;br /&gt;    Dim PrtMipString As str_PRTMIP&lt;br /&gt;    Dim PM As type_PRTMIP&lt;br /&gt;    Dim rprt As Report&lt;br /&gt;    Const TWIPS As Long = 1440&lt;br /&gt;&lt;br /&gt;    Set rprt = Reports(strName)&lt;br /&gt;    PrtMipString.strRGB = rprt.PrtMip&lt;br /&gt;    LSet PM = PrtMipString&lt;br /&gt;    &lt;br /&gt;    ' Set margins.&lt;br /&gt;    PM.xLeftMargin = 0.75 * TWIPS&lt;br /&gt;    PM.yTopMargin = 0.5 * TWIPS&lt;br /&gt;    PM.xRightMargin = 0.5 * TWIPS&lt;br /&gt;    PM.yBotMargin = 0.5 * TWIPS&lt;br /&gt;    &lt;br /&gt;    ' Update property.&lt;br /&gt;    LSet PrtMipString = PM&lt;br /&gt;    rprt.PrtMip = PrtMipString.strRGB&lt;br /&gt; &lt;br /&gt;    Set rprt = Nothing&lt;br /&gt;    &lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Dimensions&lt;/b&gt; of the Reports, Forms and other Objects are measured internally in &lt;b&gt;Twips&lt;/b&gt; rather than in &lt;b&gt;Inches&lt;/b&gt; or &lt;b&gt;Millimeters&lt;/b&gt;.   We are allowed to change  the measurements on the Property Sheets of Report, Form or other Objects in standard measurements manually, like Inches or Centimeters or in any other regional values. They are automatically converted into Twips internally.  But, in programs we have to do that work before changing the values of the Property of objects.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;1 Inch = 1440 Twips&lt;br /&gt;1 Inch   = 72 Points&lt;br /&gt;1 Point = 20 Twips&lt;br /&gt;OR &lt;br /&gt;1 Twip = 1/20 Point&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have used Constant values in the Program for &lt;b&gt;Page Size, Orientation&lt;/b&gt; and &lt;b&gt;Margins&lt;/b&gt; for simplicity. You can modify the Code to pass these values as parameters along with the Report Name, when the Program is called for each Report. This will give more flexibility and the Program can be called for Reports with different Page Settings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next we will see how to change the values on the &lt;b&gt;Columns&lt;/b&gt; Tab of the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box of &lt;b&gt;File&lt;/b&gt; Menu.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/06/network-and-print-page-setup-2.shtml&amp;amp;title=Network+And+Print+Page+Setup-2"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml"&gt;Control Tip Text and Time Delay&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;External Files List in Hyperlinks&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml"&gt;Combo Box Column Values&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml"&gt;Drill-Down Inquiry Screen-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Drill-Down Inquiry Screen&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-6422237557609454019?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=piXbIxbpF3g:khIdFa1kwA0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=piXbIxbpF3g:khIdFa1kwA0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=piXbIxbpF3g:khIdFa1kwA0:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=piXbIxbpF3g:khIdFa1kwA0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=piXbIxbpF3g:khIdFa1kwA0:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/piXbIxbpF3g" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/piXbIxbpF3g/network-and-print-page-setup-2.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/06/network-and-print-page-setup-2.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-4831096806723705812</guid><pubDate>Fri, 05 Jun 2009 05:16:00 +0000</pubDate><atom:updated>2009-06-05T10:10:02.328+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess reports</category><title>Network And Report Page Setup</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Hivy6VEV2oEhD2Y2jn_j6DhmXrs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Hivy6VEV2oEhD2Y2jn_j6DhmXrs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Hivy6VEV2oEhD2Y2jn_j6DhmXrs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Hivy6VEV2oEhD2Y2jn_j6DhmXrs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;When MS-Access Application is installed on a &lt;a href="http://www.msaccesstips.com/2008/03/sending-alerts-to-workstations.shtml"&gt;Network&lt;/a&gt;; Security is one of the major issues that the Database Developer has to tackle. This includes security of data and objects within the Database and the Database file itself. To learn more about securing a Database on Network click &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We are going to look into another issue, most often faced by &lt;a href="http://www.msaccesstips.com/2006/11/add-users-to-security-groups.shtml"&gt;Users&lt;/a&gt; and solved temporarily by alternative methods. When Ms-Access &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;Reports&lt;/a&gt; are designed for a particular Printer on the Network and when all Users share the same Printer then there are no issues.  But, any of the Users tries to print the Report on a different Printer then it is likely that the &lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Report&lt;/a&gt; may not print correctly.  The User may have access to different Printers on the Network or Local Printer.  The default &lt;b&gt;Paper Size, Page Orientation&lt;/b&gt; or &lt;b&gt;Margin&lt;/b&gt; Settings on these Printers can be different and the &lt;a href="http://www.msaccesstips.com/2007/08/reports-page-border.shtml"&gt;Report&lt;/a&gt; may not print correctly when printed.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;To overcome this issue &lt;a href="http://www.msaccesstips.com/2006/11/remove-users-from-security-groups.shtml"&gt;Users&lt;/a&gt; have to preview the Report, if necessary, open the &lt;b&gt;Page Setup&lt;/b&gt; Menu and change &lt;b&gt;Paper Size, Page orientation&lt;/b&gt; (Portrait or Landscape) and &lt;b&gt;Margins&lt;/b&gt; before sending the Report to the Printer. This can be done only if the Report &lt;b&gt;Page Setup&lt;/b&gt; Option is provided to the User. If Customized Menus and Toolbars are created for the Application this option probably may not appear in them.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For more details on Customized Menus and Toolbars visit the following Links:&lt;br /&gt; &lt;a href="http://www.msaccesstips.com/2007/07/calendar-and-toolbars.shtml"&gt;Calendar and Toolbars&lt;/a&gt;&lt;br /&gt; &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml"&gt;Custom Menus and Toolbars&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars2.shtml"&gt; Custom Menus and Toolbars-2&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;To make life easier for the User we can modify the &lt;b&gt;PrtDevMode Property&lt;/b&gt; of the Report through Program to change some of the critical parameters automatically, like &lt;b&gt;Paper Size, Page Orientation&lt;/b&gt; (Portrait or Landscape) and &lt;b&gt;Margins&lt;/b&gt; before the Report is sent to the Printer.  This ensures that the Report will print correctly on any printer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;PrtDevMode Property&lt;/b&gt; of the Report is a &lt;b&gt;94 Byte&lt;/b&gt; long structure with several parameters that can be modified through Program to make the Printer behave the way we want.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;To try out an example we will concentrate on two simple parameters for our Report.  Our sample Report is designed in &lt;b&gt;Landscape Mode&lt;/b&gt; and need to print on &lt;b&gt;A4  (210 x 297 mm)&lt;/b&gt; size Pager.  We must change the following member parameters of the &lt;b&gt;PrtDevMode Property&lt;/b&gt; of the default printer:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Orientation     -   Valid Values: 1 = Portrait, 2 = Landscape&lt;/li&gt;&lt;br /&gt;&lt;li&gt;PaperSize       - 9 = A4 (210 x 297 mm)&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;The above options (&lt;b&gt;Orientation&lt;/b&gt; and &lt;b&gt;Paper size&lt;/b&gt;) are appearing on the &lt;b&gt;Page&lt;/b&gt; Tab of the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box of &lt;b&gt;File&lt;/b&gt; Menu. We are trying to change these values at runtime through Program.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Open a new Standard Module (Global Module) in your Database and copy the following Code into the module and save it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Type str_DEVMODE&lt;br /&gt;    RGB As String * 94&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Private Type type_DEVMODE&lt;br /&gt;    strDeviceName As String * 16&lt;br /&gt;    intSpecVersion As Integer&lt;br /&gt;    intDriverVersion As Integer&lt;br /&gt;    intSize As Integer&lt;br /&gt;    intDriverExtra As Integer&lt;br /&gt;    lngFields As Long&lt;br /&gt;    intOrientation As Integer&lt;br /&gt;    intPaperSize As Integer&lt;br /&gt;    intPaperLength As Integer&lt;br /&gt;    intPaperWidth As Integer&lt;br /&gt;    intScale As Integer&lt;br /&gt;    intCopies As Integer&lt;br /&gt;    intDefaultSource As Integer&lt;br /&gt;    intPrintQuality As Integer&lt;br /&gt;    intColor As Integer&lt;br /&gt;    intDuplex As Integer&lt;br /&gt;    intResolution As Integer&lt;br /&gt;    intTTOption As Integer&lt;br /&gt;    intCollate As Integer&lt;br /&gt;    strFormName As String * 16&lt;br /&gt;    lngPad As Long&lt;br /&gt;    lngBits As Long&lt;br /&gt;    lngPW As Long&lt;br /&gt;    lngPH As Long&lt;br /&gt;    lngDFI As Long&lt;br /&gt;    lngDFr As Long&lt;br /&gt;End Type&lt;br /&gt;&lt;br /&gt;Public Sub PaperAndOrient(ByVal strName As String)&lt;br /&gt;    Const DM_PORTRAIT = 1&lt;br /&gt;    Const DM_LANDSCAPE = 2&lt;br /&gt;    Const DM_PAPERSIZE = 9&lt;br /&gt;    Dim DevString As str_DEVMODE&lt;br /&gt;    Dim DM As type_DEVMODE&lt;br /&gt;    Dim strDevModeExtra As String&lt;br /&gt;    Dim rpt As Report&lt;br /&gt;    &lt;br /&gt;    ' Opens report in Design view.&lt;br /&gt;    DoCmd.OpenReport strName, acDesign&lt;br /&gt;    Set rpt = Reports(strName)&lt;br /&gt;    &lt;br /&gt;    If Not IsNull(rpt.PrtDevMode) Then&lt;br /&gt;        strDevModeExtra = rpt.PrtDevMode&lt;br /&gt;        DevString.RGB = strDevModeExtra&lt;br /&gt;        LSet DM = DevString&lt;br /&gt;        DM.lngFields = DM.lngFields Or DM.intOrientation&lt;br /&gt;        ' Initialize fields.&lt;br /&gt;        DM.intPaperSize = DM_PAPERSIZE&lt;br /&gt;        If DM.intOrientation = DM_PORTRAIT Then&lt;br /&gt;            DM.intOrientation = DM_LANDSCAPE&lt;br /&gt;        End If&lt;br /&gt;        &lt;br /&gt;        ' Update property.&lt;br /&gt;        LSet DevString = DM&lt;br /&gt;        Mid(strDevModeExtra, 1, 94) = DevString.RGB&lt;br /&gt;        rpt.PrtDevMode = strDevModeExtra&lt;br /&gt;    End If&lt;br /&gt;    DoCmd.Close acReport, strName, acSaveYes&lt;br /&gt;    DoCmd.OpenReport strName, acViewPreview&lt;br /&gt;    Set rpt = Nothing&lt;br /&gt;    &lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;At the beginning of the Code two new User Defined Data Type &lt;b&gt;str_DEVMODE&lt;/b&gt; and &lt;b&gt;type_DEVMODE&lt;/b&gt; are declared. The &lt;a href="http://www.msaccesstips.com/2007/08/reports-page-border.shtml"&gt;Report&lt;/a&gt; &lt;b&gt;PrtDevMode&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Value is moved into this structured data area so that we can modify the required element&amp;#39;s value and update them back into the Report before printing.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RGB&lt;/b&gt; is defined as a member of the &lt;b&gt;str_DEVMODE&lt;/b&gt; with 94 Bytes long String data type. This 94 Byte data area consists of 26 different parameter values of various data types and sizes and defined accordingly under &lt;b&gt;type_DEVMODE&lt;/b&gt; data structure.  When we move the data from &lt;b&gt;str_DEVMODE&lt;/b&gt; (a single block of 94 characters) into &lt;b&gt;type_DEVMODE&lt;/b&gt; we can individually change the required value before updating it back into the Report&amp;#39;s Page Setup.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NB:&lt;/b&gt; &lt;i&gt;If the Database is implemented with Microsoft Access Security then all Users must have Report Design Change Authority to run this procedure.&lt;/i&gt;&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;To try out our Program open one of your Reports with Landscape Page Orientation in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Page Setup&lt;/b&gt; from &lt;b&gt;File&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;b&gt;Page&lt;/b&gt; Tab on the Dialog Box.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change &lt;b&gt;Orientation&lt;/b&gt; to &lt;b&gt;Portrait&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change &lt;b&gt;Paper Size&lt;/b&gt; to &lt;b&gt;A6&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the Report and open it in Print Preview to check how it looks with the change.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Close the Report after viewing.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Button&lt;/a&gt;&lt;/b&gt; on an existing Form or on a new Form and keep the Form in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt; (&lt;b&gt;Alt+Enter&lt;/b&gt; or &lt;b&gt;View- - &gt; Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;b&gt;cmdPreview&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the following Code into the Code Module (&lt;b&gt;View - -&gt; Code&lt;/b&gt;) of the Form.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub cmdPreview_Click()&lt;br /&gt;     PaperAndOrient &amp;quot;MyReport&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Replace &lt;b&gt;&amp;quot;MyReport&amp;quot;&lt;/b&gt; with your own Report Name.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the Form and open it in normal view.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;cmdPreview&lt;/b&gt; button to run the program to change the Page setup&lt;br /&gt;correctly and open it in Print Preview.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Type &lt;b&gt;PaperAndOrient &amp;quot;MyReport&amp;quot;&lt;/b&gt; in &lt;b&gt;Debug Window&lt;/b&gt; (&lt;b&gt;Ctrl+G&lt;/b&gt;) and press &lt;b&gt;Enter&lt;/b&gt; to run the Program directly without the Form and &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Open the Report again in design view and check whether the wrong changes that you have made manually in the Page Setup Dialog Box, to test the program, have now corrected through the program or not.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Next we will see how to change the values on the &lt;b&gt;Margins&lt;/b&gt; Tab of the &lt;b&gt;Page Setup&lt;/b&gt; Dialog Box through Program.&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/06/network-and-report-page-setup.shtml&amp;amp;title=Network+And+Report+Page+Setup"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;External Files List in Hyperlinks&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml"&gt;Combo Box Column Values&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml"&gt;Drill-Down Inquiry Screen-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Drill-Down Inquiry Screen&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button Animation-2&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-4831096806723705812?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=vSQ0QrKQ3SQ:ek6nWa3iyEk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=vSQ0QrKQ3SQ:ek6nWa3iyEk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=vSQ0QrKQ3SQ:ek6nWa3iyEk:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=vSQ0QrKQ3SQ:ek6nWa3iyEk:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=vSQ0QrKQ3SQ:ek6nWa3iyEk:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/vSQ0QrKQ3SQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/vSQ0QrKQ3SQ/network-and-report-page-setup.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/06/network-and-report-page-setup.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5596363151765758685</guid><pubDate>Sat, 18 Apr 2009 07:57:00 +0000</pubDate><atom:updated>2009-06-05T10:07:47.349+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Filter by Character and Sort</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/483iVblfRQHa-3TGmGyLiDTDz1o/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/483iVblfRQHa-3TGmGyLiDTDz1o/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/483iVblfRQHa-3TGmGyLiDTDz1o/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/483iVblfRQHa-3TGmGyLiDTDz1o/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Search, Find, Filter and Sort operations are necessary to organize data into manageable form so that finding required information becomes easy. We have seen some of these actions through the following earlier Posts Titled:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/12/find-or-filter-data-on-form.shtml"&gt;Find or Filter Data on Form&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/03/filtering-data-for-different-users.shtml"&gt;Filtering Data for different Users&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/04/animating-label-on-search-success.shtml"&gt;Animating Label on Search Success&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, we will try a different and easy method (for the &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;User&lt;/a&gt;) for filtering data by keying in one or more characters into a Text Box and obtain instant result, rather than Typing Search Text on Controls and Clicking on different Buttons or Tool Bars. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When the first character is entered into a Text Box (say the letter &lt;b&gt;F&lt;/b&gt;) all Records with names starting with that letter will be filtered instantly. If the filtered list is large then the next character that matches can be entered to further narrow down the list and this method can be repeated. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If &lt;b&gt;Backspace&lt;/b&gt; key is pressed to delete the last character or more characters entered in the Text Box; the filtered list will expand progressively and reverse this process.  Since, this action is instantaneous the User can get the result the moment she touches a key. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If we need values from one of these filtered records transferred to some other open form then it can be done by writing a routine on the &lt;b&gt;Double-Click&lt;/b&gt; Action at &lt;a href="http://www.msaccesstips.com/2007/06/startup-screen-design.shtml"&gt;Form&lt;/a&gt; level as well.  Double-Clicking on the left border of a particular record (&lt;b&gt;Record Selector&lt;/b&gt;) can trigger this action and can transfer required values into a different open Form. We will see sample Code for this action at the end of this Article. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A sample image of a Form is given below. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/uploaded_images/filtersort-793358.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 276px;" src="http://www.msaccesstips.com/uploaded_images/filtersort-793355.jpg" border="0" alt="Filter by Character and Sort example image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;The only limitation is that we have created this method for use on a Tabular type &lt;a href="http://www.msaccesstips.com/2007/07/animated-floating-calendar.shtml"&gt;Form&lt;/a&gt; so that several records can be viewed at one time. The earlier methods (see the references given above) were created for using on Forms with single record view. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Normally, the search or filter operation of this type will be concentrated on a single field, like the Employee Code, Company Code or Company Name; that has more relevance while looking for information. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But, here we will try to go one step further by providing a list of Field Names of the Source Object (Table or &lt;a href="http://www.msaccesstips.com/2008/02/percentage-on-total-query.shtml"&gt;Query&lt;/a&gt;) attached to the Form (in a &lt;a href="http://www.msaccesstips.com/2008/03/refresh-dependant-combo-box-contents.shtml"&gt;Combo Box&lt;/a&gt;),  so that the User can select the Field that she likes to filter the data on. This will provide more choices and flexibility. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To try this example we need the &lt;b&gt;Customers&lt;/b&gt; Table from the &lt;b&gt;Northwind.mdb&lt;/b&gt; sample database.    If you don&amp;#39;t know the location of this file then you can find this in &lt;a href="http://www.msaccesstips.com/2009/04/animating-label-on-search-success.shtml"&gt;last week&amp;#39s Post&lt;/a&gt;, the third item out of the three links given above. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Import the Customers Table. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design a Tabular Form as shown in the Image given above. I have selected only the first three fields from the Table for this example. If you would like to use all the Fields in the Table you may do so. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Expand the Form Footer Section, if it is not visible (&lt;b&gt;View - -&gt;Form Header/Footer&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If the Tool Box is not visible display it by selecting &lt;b&gt;Toolbox&lt;/b&gt; from &lt;b&gt;View&lt;/b&gt; Menu. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;De-select the &lt;b&gt;Control Wizards&lt;/b&gt; Button (the top right one); if it is already in selected state on the &lt;b&gt;ToolBox&lt;/b&gt;, so that the Wizard will not start when we select the &lt;b&gt;Combo Box&lt;/b&gt; Tool. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;b&gt;Combo Box&lt;/b&gt; Tool from the &lt;b&gt;Toolbox&lt;/b&gt; and draw a Combo Box on the &lt;b&gt;Footer Section&lt;/b&gt; of the Form as shown in the design above. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Caption&lt;/b&gt; value of the &lt;b&gt;Child Label&lt;/b&gt; of the Combo Box to &lt;b&gt;Filter/Sort Field: &lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Combo Box&lt;/b&gt; to select it and display its Property Sheet (&lt;b&gt;View- -&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values as given below: &lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name   =   cboFields&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Row Source Type   =  Field List&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Row Source  =  Customers&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Width =  1&amp;quot; &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;Text Box&lt;/b&gt; below the Combo Box. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Caption&lt;/b&gt; Value of the &lt;b&gt;Child Label&lt;/b&gt; to &lt;b&gt;FilterText: &lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value of the Text Box to &lt;b&gt;FilterText&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt;&lt;/b&gt; to the right of the Text Box and change the following Property Values as shown: &lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name  =  cmdClose&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Caption  =  Close&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;b&gt;VBA Code Module&lt;/b&gt; of the Form (&lt;b&gt;View - -&gt;Code&lt;/b&gt; or &lt;b&gt;Alt+F11&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into the Module and &lt;b&gt;Save&lt;/b&gt; the Form with the name &lt;b&gt;Customers&lt;/b&gt; or any other name you prefer. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;Dim x, rst As Recordset&lt;br /&gt;&lt;br /&gt;Private Sub cmdClose_Click()&lt;br /&gt;    DoCmd.Close&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub FilterText_KeyUp(KeyCode As Integer, Shift As Integer)&lt;br /&gt;Dim i As Integer, tmp&lt;br /&gt;&lt;br /&gt;On Error GoTo FilterText_KeyUp_Err&lt;br /&gt;i = KeyCode&lt;br /&gt;&lt;br /&gt;Select Case i&lt;br /&gt;    Case 8 'backspace key&lt;br /&gt;        Me.Refresh&lt;br /&gt;        If Len(x) = 1 Or Len(x) = 0 Then&lt;br /&gt;            x = &amp;quot;&amp;quot;&lt;br /&gt;        Else&lt;br /&gt;            x = Left(x, Len(x) - 1)&lt;br /&gt;        End If&lt;br /&gt;        GoSub setfilter&lt;br /&gt;    Case 37, 39 'left and right arrow keys&lt;br /&gt;        SendKeys &amp;quot;{END}&amp;quot; 'ignore action&lt;br /&gt;    Case 32, 48 To 57, 65 To 90, 97 To 122 'space, 0 to 9, A to Z, a to z keys&lt;br /&gt;        x = x &amp; Chr$(i)&lt;br /&gt;        Me![FilterText] = x&lt;br /&gt;        GoSub setfilter&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;FilterText_KeyUp_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;setfilter:&lt;br /&gt;  Me.Refresh&lt;br /&gt;  tmp = Nz(Me!cboFields, &amp;quot;&amp;quot;)&lt;br /&gt;  If Len(Nz(x, &amp;quot;&amp;quot;)) = 0 Then&lt;br /&gt;        Me.FilterOn = False&lt;br /&gt;  Else&lt;br /&gt;        Me.Filter = Me![cboFields] &amp;amp; &amp;quot; like '&amp;quot; &amp;amp; x &amp;amp; &amp;quot;*'&amp;quot;&lt;br /&gt;        Me.FilterOn = True&lt;br /&gt;  End If&lt;br /&gt;  Me.OrderBy = Me.RecordSource &amp;amp; &amp;quot;. &amp;quot; &amp;amp; Me!cboFields&lt;br /&gt;  Me.OrderByOn = True&lt;br /&gt;  Me![cboFields] = tmp&lt;br /&gt;  Me.FilterText.SetFocus&lt;br /&gt;  SendKeys &amp;quot;{END}&amp;quot;&lt;br /&gt;Return&lt;br /&gt;&lt;br /&gt;FilterText_KeyUp_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;FilterText_KeyUp()&amp;quot;&lt;br /&gt;Resume FilterText_KeyUp_Exit&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Close()&lt;br /&gt;    Application.SetOption &amp;quot;Behavior Entering Field&amp;quot;, 0&lt;br /&gt;    Me.FilterOn = False&lt;br /&gt;    Me.OrderByOn = False&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;    Application.SetOption &amp;quot;Behavior Entering Field&amp;quot;, 2&lt;br /&gt;    Set rst = Me.RecordsetClone&lt;br /&gt;    Me!cboFields = rst.Fields(0).Name&lt;br /&gt;    rst.Close&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Open the Form in normal View. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;The &lt;b&gt;CustomerID&lt;/b&gt; Field will appear as default value in the &lt;b&gt;Combo Box&lt;/b&gt; control. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Text Box below the Combo Box to set the focus on it. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Type the Character &lt;b&gt;F&lt;/b&gt; and you will see that all the records with &lt;b&gt;CustomerID&lt;/b&gt; values starting with the letter &lt;b&gt;F&lt;/b&gt; is filtered. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;If you look at the CustomerID Field values of the filtered records you may find that the second character of the CustomerIDs are different and three items have the letter &lt;b&gt;R&lt;/b&gt; in the second character position. Besides that the CustomerIDs are correctly sorted in Alphabetical Order. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Type the Character &lt;b&gt;R&lt;/b&gt; next to the character &lt;b&gt;F&lt;/b&gt; in the &lt;b&gt;FilterText&lt;/b&gt; control and the list narrows with starting CustomerID characters &lt;b&gt;FR&lt;/b&gt;. You can further filter and narrow down the list progressively this way, if needed. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Press &lt;b&gt;Backspace&lt;/b&gt; Key to delete the character &lt;b&gt;R&lt;/b&gt; and to leave &lt;b&gt;F&lt;/b&gt; character alone in the Text Box. The list will expand and all items starting with the letter &lt;b&gt;F&lt;/b&gt; are back in the List. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Press &lt;b&gt;Backspace&lt;/b&gt; Key again to delete the character &lt;b&gt;F&lt;/b&gt; from the Text Box.  This time the Filter action is removed and all the records are back in the Form. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NB:&lt;/b&gt; The Filter Criteria Text Values are limited to the Characters &lt;b&gt;0 to 9&lt;/b&gt; and &lt;b&gt;A to Z&lt;/b&gt; only.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want to try the Filter action on one of the other two fields you may select that Field&amp;#39;s name from the &lt;b&gt;Combo Box&lt;/b&gt; above before trying the filter action explained from &lt;b&gt;Step-19&lt;/b&gt; onwards.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Since the &lt;b&gt;CustomerID&lt;/b&gt;s are created based on the &lt;b&gt;CompanyName&lt;/b&gt; Field; trying on both those fields will give almost same result. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You may try it on the third Field &lt;b&gt;ContactName&lt;/b&gt; for different results. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The sample code given below assumes that you have Double-Clicked on the left border of a record (Record Selector) to transfer the &lt;b&gt;CustomerID&lt;/b&gt; code into &lt;b&gt;CusID&lt;/b&gt; field of another open Form; &lt;b&gt;Orders&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;Private Sub Form_DblClick(Cancel As Integer)&lt;br /&gt;Forms!Orders![CusID] = Me![CustomerID]&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/04/filter-by-character-and-sort.shtml&amp;amp;title=Filter+by+Character+and+Sort"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml"&gt;Combo Box Column Values&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml"&gt;Drill-Down Inquiry Screen-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Drill-Down Inquiry Screen&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button Animation-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml"&gt;Cardinal Text Format in Access&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5596363151765758685?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2VgfcXtLHRQ:r4zQFHS2S60:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2VgfcXtLHRQ:r4zQFHS2S60:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2VgfcXtLHRQ:r4zQFHS2S60:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=2VgfcXtLHRQ:r4zQFHS2S60:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=2VgfcXtLHRQ:r4zQFHS2S60:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/2VgfcXtLHRQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/2VgfcXtLHRQ/filter-by-character-and-sort.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/04/filter-by-character-and-sort.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-8274883395698364294</guid><pubDate>Sat, 11 Apr 2009 07:07:00 +0000</pubDate><atom:updated>2009-04-11T11:51:48.825+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess animation</category><title>Animating Label on Search Success</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/IPmZC_jRey8cjzR9Z8_kDzMt29U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IPmZC_jRey8cjzR9Z8_kDzMt29U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/IPmZC_jRey8cjzR9Z8_kDzMt29U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IPmZC_jRey8cjzR9Z8_kDzMt29U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We have seen how to &lt;a href="http://www.msaccesstips.com/2007/12/find-or-filter-data-on-form.shtml"&gt;find or filter &lt;/a&gt;records using values entered into a text box.  We have used three different methods to find or filter data after entering text or numeric search values into a text box. But, we have not used any visual indicator to announce that the search operation was successful or not.  If the search operation was successful then the record that matches the criteria will become current or filtered, that was the only clue to know that the search was successful.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here, we will see how to animate a Label few times with an indicative message; announcing the search operation was successful or not..&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;To try an example with the sample VBA Code given below; import the &lt;b&gt;Customers Table&lt;/b&gt; and &lt;b&gt;Customers Form&lt;/b&gt; from &lt;b&gt;Northwind.mdb&lt;/b&gt; sample database.  If you are not sure, where to find this database, check the location &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office11\Samples&lt;/font&gt; Folder (in Office2003).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;b&gt;Customers&lt;/b&gt; form in design view.&lt;/li&gt; &lt;br /&gt;&lt;li&gt;Expand the &lt;a href="http://www.msaccesstips.com/2007/12/progress-meter.shtml"&gt;Form&lt;/a&gt; &lt;b&gt;Footer Section&lt;/b&gt; to create few controls for Quick Search operation and for our magic label animation.  Check the sample image of the Form given below with controls added at the Footer of the Form:&lt;/li&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/uploaded_images/flashlabel1-735207.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 260px;" src="http://www.msaccesstips.com/uploaded_images/flashlabel1-735203.jpg" border="0" alt="Search Form Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;li&gt;Draw a Label on the Form &lt;b&gt;Footer Section&lt;/b&gt; and change its &lt;b&gt;Caption&lt;/b&gt; to &lt;b&gt;Customer ID to Find: &lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Draw a Text Box to the right of the Label and change its &lt;b&gt;Name&lt;/b&gt; Property (&lt;b&gt;View - -&gt; Properties&lt;/b&gt; or &lt;b&gt;Alt+Enter&lt;/b&gt;) Value to &lt;b&gt;xFind&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Command Button to the right of the Text Box and change its &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;b&gt;cmdFind&lt;/b&gt;.  Change the &lt;b&gt;Caption&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button &lt;/a&gt;to &lt;b&gt;&lt;&lt; Find&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Label&lt;/a&gt; below the Text Box and change the following Property Values shown against each Property:&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name    =   lblMsg&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Caption  =   x&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Visible    =   False&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the &lt;a href="http://www.msaccesstips.com/2007/05/opening-access-forms.shtml"&gt;Form&lt;/a&gt; (&lt;b&gt;View - -&gt; Code&lt;/b&gt; or &lt;b&gt;Alt+F11&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into the Form Module and save the Form:&lt;/li&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;Dim backcolor As Long, forecolor As Long&lt;br /&gt;Dim L As Integer&lt;br /&gt;&lt;br /&gt;Private Sub cmdFind_Click()&lt;br /&gt;'---------------------------------------------------------------&lt;br /&gt;'Author : a.p.r. pillai&lt;br /&gt;'Date    : April-2009&lt;br /&gt;'URL     : www.msaccesstips.com&lt;br /&gt;'All Rights Reserved by www.msaccesstips.com&lt;br /&gt;'---------------------------------------------------------------&lt;br /&gt;Dim m_Find, rst As Recordset&lt;br /&gt;&lt;br /&gt;On Error GoTo cmdFind_Click_Err&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;backcolor = -2147483633&lt;br /&gt;&lt;br /&gt;m_Find = Me![xFind]&lt;br /&gt;If IsNull(m_Find) Then&lt;br /&gt;    Exit Sub&lt;br /&gt;End If&lt;br /&gt;Set rst = Me.RecordsetClone&lt;br /&gt;rst.FindFirst &amp;quot;CustomerID = '&amp;quot; &amp;amp; [m_Find] &amp;amp; &amp;quot;'&amp;quot;&lt;br /&gt;If Not rst.NoMatch Then&lt;br /&gt;    Me.Bookmark = rst.Bookmark&lt;br /&gt;    Me.lblMsg.Caption = &amp;quot;** Successful ***&amp;quot;&lt;br /&gt;    forecolor = 16711680&lt;br /&gt;    Me.lblMsg.forecolor = forecolor&lt;br /&gt;Else&lt;br /&gt;    Me.lblMsg.Caption = &amp;quot;Sorry, Not found...!&amp;quot;&lt;br /&gt;    forecolor = 255&lt;br /&gt;    Me.lblMsg.forecolor = forecolor&lt;br /&gt;End If&lt;br /&gt;L = 0&lt;br /&gt;Me.lblMsg.Visible = True&lt;br /&gt;Me.TimerInterval = 250&lt;br /&gt;&lt;br /&gt;cmdFind_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdFind_Click_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;cmdFind_Click()&amp;quot;&lt;br /&gt;Resume cmdFind_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Timer()&lt;br /&gt;L = L + 1&lt;br /&gt;Select Case L&lt;br /&gt;    Case 1, 3, 5, 7, 9, 11, 13, 15, 17&lt;br /&gt;        Me.lblMsg.Visible = True&lt;br /&gt;    Case 2, 4, 6, 8, 10, 12, 14, 16, 18&lt;br /&gt;        Me.lblMsg.Visible = False&lt;br /&gt;    Case 19&lt;br /&gt;       Me.lblMsg.forecolor = forecolor&lt;br /&gt;       Me.lblMsg.Visible = True&lt;br /&gt;       Me.TimerInterval = 0&lt;br /&gt;End Select&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub xFind_GotFocus()&lt;br /&gt;     Me.lblMsg.Visible = False&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The first two lines of Code should go at the Global level of the Form Module.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the Customers form in normal View to try out our creation. When you open the form the Label that we have created below the Text Box will not be visible.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Type record number 55 in the &lt;b&gt;Record Navigation&lt;/b&gt; control below.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Highlight the &lt;b&gt;CustomerID&lt;/b&gt; code and press &lt;b&gt;Ctrl+C&lt;/b&gt; to copy the Customer Code into Clipboard.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Type &lt;b&gt;1&lt;/b&gt; in the record navigation control to make the first record as current.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Text Search &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Control&lt;/a&gt; at the Form Footer to select it and press &lt;b&gt;Ctrl+V&lt;/b&gt; to Paste the Customer Code from Clipboard.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button &lt;/a&gt;to find the first record that matches the Customer Code.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;If the search operation was successful, the first record that matches the &lt;b&gt;CustomerID&lt;/b&gt; will become current and the Label below the Text Box will be visible and will flash nine times with the text message &lt;b&gt;** Successful **&lt;/b&gt; and stays on the screen.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Make the first record as current again and make some change in the &lt;b&gt;CustomerID&lt;/b&gt; in the search Text Box so that the search operation will fail with the modified Value.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button &lt;/a&gt;to search for the wrong CustomerID Code.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;This time we will get the &lt;b&gt;Sorry, Not Found…!&lt;/b&gt; Message flashing nine times and the message stays on the screen.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this example we have made the label visible and hidden intermittently within an interval time of 250 Milliseconds.  This method is ideal on all type of Forms with different backgrounds, like the one we have used with a &lt;a href="http://www.msaccesstips.com/2009/04/form-background-with-gradient-color.shtml"&gt;Background picture&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can make the Label flash by changing the text Color (rather than hiding and displaying the label as we did in the above example) with the same timing mechanism, if the Form background have a particular Color.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a copy of the &lt;b&gt;Customers&lt;/b&gt; Form with the name &lt;b&gt;Customers2&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the Form in Design View and display the Form’s Property Sheet.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Find the &lt;b&gt;Picture&lt;/b&gt; Property and delete the &lt;b&gt;.WMF&lt;/b&gt; image file path name. This action will display a message asking to reconfirm the delete action and respond to remove the entry.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Remove the &lt;b&gt;After Update&lt;/b&gt; property value also. There is a Macro attached here to run on the after update event of the form.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Without closing the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet Click on the Footer of the Form and change &lt;b&gt;Back Color&lt;/b&gt; Property value to &lt;b&gt;-2147483633&lt;/b&gt;. This is the normal Form background color, when you open a new form in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the label below the Text Box and change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Back Style = Transparent&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Special Effect = Flat&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Border Style = Transparent&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Replace the following &lt;b&gt;Select Case …. End Select&lt;/b&gt; code segment with the Code given below, in the &lt;b&gt;Sub Form_Timer()&lt;/b&gt; Event Procedure:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Select Case L&lt;br /&gt;    Case 1, 3, 5, 7, 9, 11, 13, 15, 17&lt;br /&gt;        Me.lblMsg.forecolor = forecolor&lt;br /&gt;    Case 2, 4, 6, 8, 10, 12, 14, 16, 18&lt;br /&gt;        Me.lblMsg.forecolor = backcolor&lt;br /&gt;    Case 19&lt;br /&gt;       Me.lblMsg.forecolor = forecolor&lt;br /&gt;       Me.lblMsg.Visible = True&lt;br /&gt;       Me.TimerInterval = 0&lt;br /&gt;End Select&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The lines under the first two &lt;b&gt;Case…&lt;/b&gt; statements only we have changed in the above code segment to change the &lt;b&gt;Color&lt;/b&gt; of the &lt;b&gt;Font&lt;/b&gt;.  &lt;br /&gt;&lt;br /&gt;The first statement gives the Font with &lt;b&gt;Blue Color&lt;/b&gt;, if the search operation was successful otherwise &lt;b&gt;Red Color&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;The line under the second &lt;b&gt;Case…&lt;/b&gt; statement replaces the &lt;b&gt;Font Color&lt;/b&gt; with the Form&amp;#39;s &lt;b&gt;Background Color&lt;/b&gt; making the text on the Label invisible. &lt;br /&gt;&lt;br /&gt;When the value in the control variable &lt;b&gt;L&lt;/b&gt; is an Odd Number the line under the first &lt;b&gt;Case…&lt;/b&gt; statement executes, when it is Even Number the line under the second &lt;b&gt;Case…&lt;/b&gt; statement executes.  This happens interchangeably at every 250 milliseconds interval; making the label animate nine times. When the value in the Control Variable &lt;b&gt;L = 19&lt;/b&gt;; the &lt;b&gt;Interval Timer&lt;/b&gt; is turned off and the Label&amp;#39;s &lt;b&gt;Font Color&lt;/b&gt; is changed according to the search result (&lt;b&gt;Blue&lt;/b&gt; or &lt;b&gt;Red&lt;/b&gt;) and keeps the Label visible on the Form till the User Clicks on the Text Box again to enter a new search criterion.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Save the &lt;a href="http://www.msaccesstips.com/2008/01/progress-counter.shtml"&gt;Form&lt;/a&gt; and open it in normal view.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Repeat the procedure explained under &lt;b&gt;Steps-10 to 17&lt;/b&gt; above.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;This time the Label will flash with Blue Color when the search result is successful and with Red Color when the search fails. In both situations the colors are exchanged with the background color intermittently with the Form &lt;b&gt;Background Color&lt;/b&gt; Value &lt;b&gt;-2147483633&lt;/b&gt;. &lt;br /&gt;&lt;br /&gt;If you want to slow down the action then increase the interval time value from 250 Milliseconds to a higher Value or reduce it to flash the Label faster.&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/04/animating-label-on-search-success.shtml&amp;amp;title=Animating+Label+on+Search+Success"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml"&gt;Drill-Down Inquiry Screen-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Drill-Down Inquiry Screen&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button Animation-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml"&gt;Cardinal Text Format in Access&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Custom Report Wizard&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-8274883395698364294?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=YoJaCuTmkYo:DtyMLR3HlQw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=YoJaCuTmkYo:DtyMLR3HlQw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=YoJaCuTmkYo:DtyMLR3HlQw:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=YoJaCuTmkYo:DtyMLR3HlQw:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=YoJaCuTmkYo:DtyMLR3HlQw:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/YoJaCuTmkYo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/YoJaCuTmkYo/animating-label-on-search-success.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/04/animating-label-on-search-success.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5546035204542947471</guid><pubDate>Sat, 04 Apr 2009 13:23:00 +0000</pubDate><atom:updated>2009-04-04T18:14:52.646+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess forms</category><title>Form Background with Gradient Color</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/fBupc9f_AKO7vVq-S2PY0f7K_CE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fBupc9f_AKO7vVq-S2PY0f7K_CE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/fBupc9f_AKO7vVq-S2PY0f7K_CE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fBupc9f_AKO7vVq-S2PY0f7K_CE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Form background pictures are not only used for giving the Form a different look but also for other useful purposes as well. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example, if the user is keying in data from a pre-printed Document like a Telephone Bill or Electricity Bill etc.; it is a good idea to scan an image of this Document and use it as the Data Entry Form’s background picture.  The Data Fields can be positioned in appropriate locations on the image matching the physical Document so that it will be easier for the user to find information on the Document and key-in exactly on the same locations on the Form. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Microsoft Access &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Form Wizard &lt;/a&gt;have several images to use as background picture, but I didn’t find the one that I need; the one with a gradient background. So, I thought I will make one of my own and use it. &lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/uploaded_images/switchboard-778457.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 276px;" src="http://www.msaccesstips.com/uploaded_images/switchboard-778454.jpg" border="0" alt="Main Switchboard Image with Gradient Background" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;The steps that I have taken are given below to create the image for the &lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Form&lt;/a&gt; Background picture. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Opened a new Microsoft Word Document and gone through the following steps to create a &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Gradient&lt;/a&gt; Bit Map Image:&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Selected &lt;b&gt;Format - -&gt;Background - -&gt; Fill Effects.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Under &lt;b&gt;Colors&lt;/b&gt; options selected &lt;b&gt;One Color.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Clicked on the &lt;b&gt;Color 1&lt;/b&gt; drop down control and selected a light color.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Used the &lt;b&gt;Darker/Lighter&lt;/b&gt; slider control to adjust the color tone.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Selected the &lt;b&gt;Horizontal&lt;/b&gt; Radio Button under &lt;b&gt;Shading Styles.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Clicked on one of the Style &lt;b&gt;Variants.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Clicked &lt;b&gt;OK&lt;/b&gt; to apply the selected shade as Background of the Word Document.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Maximized the Word Document Window.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Pushed the &lt;b&gt;Prt Scrn&lt;/b&gt; key (at the top row right side). The full screen image is now captured and copied to Clipboard.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Opened MS-Paint Program. You can find this in &lt;b&gt;Start - - &gt; Programs - - &gt; Accessories.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Displayed the &lt;b&gt;Toolbox (View - -&gt;Toolbox&lt;/b&gt; or press &lt;b&gt;Ctrl+T&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Selected the &lt;b&gt;Select&lt;/b&gt; Tool (the one at Top right with a rectangle picture).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Drawn a rectangle from left top corner of the gradient image area to right bottom corner to select the image large enough for my &lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Form&lt;/a&gt;&amp;#39s width and height. If you find the width is not enough to cover your form then change the Page Orientation of the Word Document into Landscape before capturing it in MS-Paint.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Used &lt;b&gt;Ctrl+C&lt;/b&gt; to copy the selected area into Clipboard.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Clicked outside the selected area to deselect the earlier selection.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Selected &lt;b&gt;Clear Image&lt;/b&gt; from &lt;b&gt;Image&lt;/b&gt; Menu (&lt;b&gt;Ctrl+Shift+N&lt;/b&gt;) to clear the Canvas. Inspected the right Scroll Bar to check whether it is positioned at the top or not. It was positioned slightly down so I dragged it up to the top. Similarly adjusted the Scroll bar at the bottom to position at the left end.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Pressed &lt;b&gt;Ctrl+V&lt;/b&gt; to paste the copied image from the Clipboard.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Clicked outside the pasted image to de-select it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Dragged the Sizing control at the bottom of the Canvas up and stopped at the edge of the pasted image to eliminate the white area of the canvas.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Similarly adjusted the right side of the image.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Selected &lt;b&gt;Save&lt;/b&gt; from &lt;b&gt;File&lt;/b&gt; Menu to save the image at a convenient location with a name.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;If you were with me so far then we will enter into the next stage of implementing the gradient image as background picture.  But, there are some limitations to use images like this one as background picture, but we can overcome this with a little trick. If you are thinking about the increase in size of the database then you are in the right direction.  If you are considering the idea of saving the image in &lt;b&gt;.jpeg&lt;/b&gt; or &lt;b&gt;.GIF&lt;/b&gt; format; then you are far ahead of me. Saving the image in &lt;b&gt;.GIF&lt;/b&gt; format in MS-Paint will not give you a good quality image.  If you have the software like &lt;b&gt;Adobe Photoshop&lt;/b&gt; then you can make a better quality .GIF image. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will do another trick to use the &lt;b&gt;.bmp&lt;/b&gt; image itself to maintain the background image quality without affecting the database size. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But, first let us see how to apply the gradient image as the &lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml"&gt;Form&lt;/a&gt;&amp;#39;s Background picture. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Before opening your database if you would like to check the present size of your database you may open Windows Explorer, check and note down the current size of the database.  I suggest you better &lt;a href="http://www.msaccesstips.com/2008/06/repairing-compacting-database-with-vba.shtml"&gt;Compact&lt;/a&gt; the Database before you take its file size. You may check it again after the background picture is added to a &lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Form&lt;/a&gt; to find the difference. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open your Database and open a Form in Design View or create a new one.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the Form (&lt;b&gt;View - -&gt; Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Find the &lt;b&gt;Picture&lt;/b&gt; Property and click on it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the build button (&lt;b&gt;…&lt;/b&gt;) at the right side of the Property Sheet and click on it to browse to the location of the image you have saved and select the image.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The next four Properties are used for formatting and displaying the Background Picture.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;li&gt;Picture Type&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Picture Size Mode&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Picture Alignment&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Picture Tiling&lt;/li&gt;&lt;br /&gt;&lt;/font&gt;   &lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;The &lt;b&gt;Picture Type&lt;/b&gt; Property has two choices &lt;b&gt;Embedded&lt;/b&gt; or &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/09/link-external-tables-with-vba.shtml"&gt;Linked&lt;/a&gt;&lt;/b&gt; to select from and the default value is &lt;b&gt;embedded&lt;/b&gt;. The embedded option is provided for invoking the default Image Editor Program from within MS-Access by double-clicking on the image and to make changes to the image, if needed.  To facilitate this; the necessary image editor program invocation information is also stored along with the image in the database, resulting a substantial increase of the database size for each image you add this way on your Form or &lt;a href="http://www.msaccesstips.com/2007/10/dynamic-report.shtml"&gt;Report&lt;/a&gt;. But, the background image inserted this way cannot be edited by double-clicking on the background as we do on the inserted image as an &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;OLE&lt;/a&gt; object, on the Form. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A better choice is &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/06/linking-with-ibm-as400-tables.shtml"&gt;Linked&lt;/a&gt;&lt;/b&gt; option that will keep the image outside and the database size is not affected. In either case the image should go along with your database in the same location of the image wherever you take your database. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Picture Size Mode&lt;/b&gt; have three options &lt;b&gt;Clip&lt;/b&gt; (default) displays the picture in actual size wherever you position it by setting one of the &lt;b&gt;Picture Alignment&lt;/b&gt; property Values (&lt;b&gt;Top Left, Top Right, Bottom Right, Bottom Left, Center&lt;/b&gt; and &lt;b&gt;Form Center&lt;/b&gt;). The &lt;b&gt;Center&lt;/b&gt; option will position the image vertically and horizontally centered on the Form and the &lt;b&gt;Form Center&lt;/b&gt; option will position the image vertically centered at the left side. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Stretch&lt;/b&gt; &lt;i&gt;Picture Size Mode&lt;/i&gt; option will stretch the image to fit the dimension of the Form and result in distortion of the image, if it is a picture of something. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Zoom&lt;/b&gt; &lt;i&gt;Picture Size Mode&lt;/i&gt; option will attempt to maintain the right proportions of the image when stretched to match the dimensions of the Form.  But both the &lt;b&gt;Stretch&lt;/b&gt; and &lt;b&gt;Zoom&lt;/b&gt; options will show stretch marks when the Form is restored to its original size. This is very much evident when a &lt;b&gt;.jpeg&lt;/b&gt; or &lt;b&gt;.GIF&lt;/b&gt; image is used. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;We can modify our earlier &lt;b&gt;.bmp&lt;/b&gt; file to a &lt;b&gt;one pixel&lt;/b&gt; width image and &lt;b&gt;Tile&lt;/b&gt; it across the Form that will give a good quality gradient picture effect and the image size also will be small. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open the earlier saved &lt;b&gt;.bmp&lt;/b&gt; image in &lt;b&gt;MS-Paint&lt;/b&gt; Program.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Attributes…&lt;/b&gt; from &lt;b&gt;Image&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Width&lt;/b&gt; Value to &lt;b&gt;1&lt;/b&gt; and let the &lt;b&gt;Height&lt;/b&gt; value remain without change.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check the &lt;b&gt;Units&lt;/b&gt; selected is &lt;b&gt;Pixels&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Save the image with a different name.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the name of the background image to the new image in the &lt;b&gt;Picture&lt;/b&gt; property of the Form.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Caution:&lt;/b&gt; Do not attempt to use the &lt;b&gt;Picture Size Mode&lt;/b&gt; property options &lt;b&gt;Stretch&lt;/b&gt; or &lt;b&gt;Zoom&lt;/b&gt;; MS-Access will hang up.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Set the &lt;b&gt;Picture Tiling&lt;/b&gt; Property Value to &lt;b&gt;Yes&lt;/b&gt; and save the Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the Form in Normal View and enjoy your creation.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/04/form-background-with-gradient-color.shtml&amp;amp;title=Form+Background+with+Gradient+Color"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Drill-Down Inquiry Screen&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button Animation-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml"&gt;Cardinal Text Format in Access&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Custom Report Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Custom Made Form Wizard&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5546035204542947471?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RLtEY1eczLM:lTe1io3-pLI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RLtEY1eczLM:lTe1io3-pLI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RLtEY1eczLM:lTe1io3-pLI:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RLtEY1eczLM:lTe1io3-pLI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RLtEY1eczLM:lTe1io3-pLI:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/RLtEY1eczLM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/RLtEY1eczLM/form-background-with-gradient-color.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/04/form-background-with-gradient-color.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-2562909303705084467</guid><pubDate>Fri, 27 Mar 2009 17:30:00 +0000</pubDate><atom:updated>2009-03-27T22:35:41.011+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>MS-Access and Reference Library</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/pLgcEef3F_WTaDcJg8syWgawsl4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pLgcEef3F_WTaDcJg8syWgawsl4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/pLgcEef3F_WTaDcJg8syWgawsl4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pLgcEef3F_WTaDcJg8syWgawsl4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We are using several Object Libraries besides the default References Library during the course of developing an Access Database.   &lt;b&gt;Microsoft Data Access Objects (DAO), Microsoft ActiveX Data Objects (ADODB), Visual Basic for Application (VBA)&lt;/b&gt; and so on. These are essential to create Data Processing Routines in VBA. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have briefly touched this subject in my first Article in this site: &lt;a href="http://www.msaccesstips.com/2006/09/command-button-animation.shtml"&gt;Command Button Animation&lt;/a&gt; and advised to link these files to your Database manually before attempting to run the Program given in there. A List of essential Library Files and the procedures to attach them to the Database manually also explained there. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Some of these Library References like: &lt;b&gt;Microsoft Access 9.0 Object Library, Visual Basic for Applications, OLE Automation&lt;/b&gt; are attached automatically when a new database is created and others are added manually. We add new reference Libraries to use interesting features extended by them, which are not available in Microsoft Access. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have used &lt;b&gt;Microsoft Office Library&lt;/b&gt; (&lt;font class=”colrgreen”&gt;Office&lt;/font&gt;) to create customized &lt;a href="http://www.msaccesstips.com/2006/09/msgbox-with-office-assistant.shtml"&gt;Message Boxes&lt;/a&gt;, &lt;a href="http://www.msaccesstips.com/2008/01/msgbox-with-options-menu.shtml"&gt;Option Baloons&lt;/a&gt; and &lt;a href="http://www.msaccesstips.com/2008/02/office-assistant-with-check-box-menu.shtml"&gt;Check-Boxes&lt;/a&gt; etc. with &lt;b&gt;Office Assistant&lt;/b&gt; to capture user responses in an interesting way. We have created a Wizard to &lt;a href="http://www.msaccesstips.com/2008/02/selection-of-office-assistant.shtml"&gt;select Office Assistant&lt;/a&gt; of your choice in Access, without using the &lt;b&gt;Option&lt;/b&gt; provided by Office Assistant. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Databases and Tables can be accessed in VBA only when we add Microsoft Data Access Objects (&lt;b&gt;DAO&lt;/b&gt;) or Microsoft ActiveX Data Objects (&lt;b&gt;ADODB&lt;/b&gt;) Library Files to Access Database. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you have written some common Functions of your own then you can save them in a separate database on Server and attach it as a Library Database so that you don&amp;#39;t have to copy and paste those &lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Functions&lt;/a&gt; in other Databases. &lt;br /&gt;&lt;br /&gt;You can use &lt;b&gt;Object Browser&lt;/b&gt; of VBA (&lt;b&gt;View - -&gt; Object Browser&lt;/b&gt;) to browse the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Properties&lt;/a&gt; and Methods extended by a particular Library. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Most of the time we use a fixed set of Library References in our Database and these are attached manually (&lt;b&gt;Tools - -&gt;References&lt;/b&gt;) one by one after opening the VBA Editing Window. Even though this is only a one-time exercise we can automate this and it is useful to quickly restore the links if they are lost as well. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First let us look at the few steps that we need to take to accomplish this. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Prepare a list of Library References and save it in a Text File, on Server if you are developing databases to use on a Network.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;B.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Write a VBA routine to read this list from the Text File and attach them to the Project.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;To prepare the required Object Library References List we must know what are these files and where on the Disk they can be located.&lt;br /&gt;Assume that we need to know what is the physical file name and location representing the Reference Library Description &lt;b&gt;Microsoft DAO 3.6 Object Library&lt;/b&gt; in the &lt;b&gt;Available References&lt;/b&gt; list. &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;To find out this manually, open VBA Module Window (&lt;b&gt;View - -&gt; Code&lt;/b&gt; or &lt;b&gt;Alt+F11&lt;/b&gt;), select &lt;b&gt;Tools- - &gt;References&lt;/b&gt; and find the item with the description &lt;b&gt;Microsoft DAO 3.6 Object Library&lt;/b&gt; among the list of other Microsoft Reference Library Files, see the image given below. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msaccesstips.com/uploaded_images/reflibrary-712004.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 259px;" src="http://www.msaccesstips.com/uploaded_images/reflibrary-712001.jpg" border="0" alt="Reference Library Description Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When you select the file; its &lt;b&gt;Description&lt;/b&gt;, the physical &lt;b&gt;File Pathname&lt;/b&gt; and &lt;b&gt;Language&lt;/b&gt; are displayed. You can write down the Pathname to prepare the list, if you want to. But, we will do half of the task differently. We can attach the required files manually and prepare the list with a small VBA Routine.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Following is a list of References that I use regularly to start with my Projects and we will use them as an example: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msaccesstips.com/uploaded_images/reflibrary2-761982.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 259px;" src="http://www.msaccesstips.com/uploaded_images/reflibrary2-761979.jpg" border="0" alt="Selected Project Reference Library List" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The first three items will be automatically selected by MS-Access when you create a new Database. Others must be added manually. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Attach the above list of Library References manually.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following lines of Code into a Standard Module of your Project and save it.&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Public Sub ReferenceList()&lt;br /&gt;Dim Ref As Reference&lt;br /&gt;For Each Ref In Application.References&lt;br /&gt;   Debug.Print Ref.FullPath&lt;br /&gt;Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Press &lt;b&gt;Ctrl+G&lt;/b&gt; to display the Debug Window (Immediate Window), if it is not already visible. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click in the middle of the Code and press &lt;b&gt;F5&lt;/b&gt; to Run it and print the following Path Names of the selected Reference Library Files in the Debug Window.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C:\Program Files\Microsoft Office\OFFICE11\MSACC.OLB&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C:\WINDOWS\system32\stdole2.tlb&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C:\Program Files\Common Files\system\ado\msado15.dll&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL&lt;/li&gt;&lt;br /&gt;&lt;li&gt;C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB&lt;/li&gt;&lt;br /&gt;&lt;li&gt;D:\MDBS\aprRefLib.mde&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The internal names (&lt;b&gt;Project Names&lt;/b&gt;) of the above Library Files are different and it is important to know about it because if we need to remove any of this library items from the Current Project then you must use the &lt;b&gt;Project Name&lt;/b&gt; in programs rather than using the above file names. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When you create Ms-Access database with the name &lt;b&gt;abcd.mdb&lt;/b&gt;; by default the same name &lt;b&gt;abcd&lt;/b&gt; will be inserted into the &lt;b&gt;Project Name control&lt;/b&gt; in the database.  You can check the Project Name of your database selecting &lt;b&gt;Tools&lt;/b&gt; Menu in the VBA Editing Window. You will find a Menu Option like &lt;b&gt;abcd Properties&lt;/b&gt;. You can open this option and set a different name in the &lt;b&gt;Project Name&lt;/b&gt; control, if needed. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; But, it is important that you should not use any names of your Standard Modules for the Project Name. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can read this Property Value in programs or in Debug Window using the statement &lt;font class="colrgreen"&gt;x =  Application.GetOption(&amp;quot;Project Name&amp;quot;)&lt;/font&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Or, modify the Project Name with the statement like &lt;font class="colrgreen"&gt; Application.SetOption &amp;quot;Project Name&amp;quot;, &amp;quot;Myabcd&amp;quot;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The List of Library Files given above; also have unique Project Names and these are the Internal Object Library Reference names that will appear in our database, when linked. You can check their names by opening the &lt;b&gt;Object Browser (View - -&gt; Object Browser&lt;/b&gt; or &lt;b&gt;F2&lt;/b&gt;) and clicking on the &lt;b&gt;&lt;All Libraries&gt;&lt;/b&gt; drop down control. Among the list you can see that your own current database Project Name &lt;b&gt;abcd&lt;/b&gt; is also appearing in the list. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Let us inspect the &lt;b&gt;Project Names&lt;/b&gt; of the first three files in the list given above. &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;VBA&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Access&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Stdole&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;When you create a new database MS-Access attaches the above three references by default and they are important too. So we will exclude them from our add/remove operations. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These names are unique irrespective of which Version of Access you are using and the same goes for the other Library References as well. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you attempt to attach a different version of the Reference Library File with the same &lt;b&gt;Project Name&lt;/b&gt; then a conflict takes place. We have to check for the following two more References to avoid removing them before attaching items from our list. &lt;br /&gt;&lt;br /&gt;&lt;li&gt;abcd (current database project name)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;aprRefLib (you can read this as your own Function Library Project Name and I will come to that later in this Article.)&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Leaving aside the above five items we are left with the following four Reference Libraries selected out of the eight items listed above to attach to our new Projects automatically: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;C:\Program Files\Common Files\Microsoft Shared\DAO\dao360.dll &lt;br /&gt;C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL&lt;br /&gt;C:\Program Files\Common Files\system\ado\msado15.dll&lt;br /&gt;C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open &lt;b&gt;NotePad.Exe&lt;/b&gt;, Copy and Paste the above File Names and save it on your Server common location where all your MS-Access Projects are installed.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Let us call the Server &lt;b&gt;PathName&lt;/b&gt; (the Location and File Name) of the target text file as &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;\\hosfs03\InhouseSys\CommonLib\RefLib.txt&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;B.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The first stage of our preparation is over. The next thing what we need is a VBA Program that can read the above Text File contents and link the Reference Library files shown in the second image above automatically to your new Project. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I will give the VBA Routines below, but you have two choices to decide where to place the code so that it is easier to use in all of your Projects without duplicating the code. The second choice is to copy the Code into your new Projects and run it from there, which I don&amp;#39;t advise you to do. Instead take the first option and do little ground work now by following the few steps given below.  This will make your future development processes easier without duplicating common Programs in all your other Projects. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you have not started to build a Reference Library Database of your own so far then this is the time to start doing it and you will find how useful it is. It is not that hard to do it either. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a new Database with the name &lt;b&gt;MyLib.mdb&lt;/b&gt; and save it to your Server Common Location. Let us take this location address same as the one we have saved our Text File with the list.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the VBA Editing Window (&lt;b&gt;Alt+F11&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Standard Module (&lt;b&gt;Insert - -&gt;Module&lt;/b&gt;) to create an empty Code Module with the name &lt;b&gt;Module1&lt;/b&gt;. You may change the name of the Module after displaying its Property Sheet (&lt;b&gt;View - -&gt;Properties Window&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into the Module; save and close the VBA Editing Window.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function AddReferences()&lt;br /&gt;Dim j As Integer, i As Integer, msg As String&lt;br /&gt;Dim Ref As Reference, RefObj As Object&lt;br /&gt;Dim RefPath As String, LibName As String&lt;br /&gt;Dim LibPath As String, libAttached() As String&lt;br /&gt;Dim refcount As Integer, chk_flag As Boolean&lt;br /&gt;Dim lib_Attached As String, validate As Boolean&lt;br /&gt;&lt;br /&gt;Const LibraryList As String = &amp;quot;\\hosfs03\InhouseSys\CommonLib\RefLib.txt&amp;quot;&lt;br /&gt;&lt;br /&gt;On Error GoTo AddReferences_Err&lt;br /&gt;&lt;br /&gt;validate = Ref_Retain_Remove()&lt;br /&gt;If validate = False Then&lt;br /&gt;   msg = &amp;quot;Errors Encountered in Validation check, Program aborted. &amp;quot;&lt;br /&gt;   Exit Function&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set RefObj = Application.References&lt;br /&gt;refcount = Application.References.Count&lt;br /&gt;ReDim libAttached(1 To refcount) As String&lt;br /&gt;i = 0&lt;br /&gt;'Prepare list of exiting attached Library Files&lt;br /&gt;For Each Ref In RefObj&lt;br /&gt;    i = i + 1&lt;br /&gt;    libAttached(i) = Ref.FullPath&lt;br /&gt;Next&lt;br /&gt;'Open text file with List of required Reference Library files&lt;br /&gt;Open LibraryList For Input As #1&lt;br /&gt;msg = ""&lt;br /&gt;Do While Not EOF(1)&lt;br /&gt;    Input #1, LibPath&lt;br /&gt;    chk_flag = False&lt;br /&gt;    For j = 1 To i&lt;br /&gt;'check for missing cases&lt;br /&gt;        lib_Attached = libAttached(j)&lt;br /&gt;        If libAttached(j) = LibPath Then&lt;br /&gt;            chk_flag = True&lt;br /&gt;            Exit For&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;    If chk_flag = False Then&lt;br /&gt;'Reference found missing, add to the Project&lt;br /&gt;        Set RefObj = Application.References.AddFromFile(LibPath)&lt;br /&gt;        msg = msg &amp; LibPath &amp; vbCr&lt;br /&gt;    End If&lt;br /&gt;Loop&lt;br /&gt;Close #1&lt;br /&gt;&lt;br /&gt;If Len(msg) &amp;lt;&amp;gt; 0 Then&lt;br /&gt;    msg = &amp;quot;Following References Attached: &amp;quot; &amp;amp; vbCr &amp;amp; vbCr &amp;amp; msg&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;MsgBox msg, , &amp;quot; AddReferences()&amp;quot;&lt;br /&gt;&lt;br /&gt;AddReferences_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;AddReferences_Err:&lt;br /&gt;MsgBox Err.Description, , "AddReferences()"&lt;br /&gt;Resume AddReferences_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;Public Function Ref_Retain_Remove() As Boolean&lt;br /&gt;Dim Ref As Reference, Reflist(), exclusion(1 To 5) As String&lt;br /&gt;Dim ref_count As Integer, strRefName As String&lt;br /&gt;Dim i As Integer, j As Integer, chk_flag As Boolean&lt;br /&gt;&lt;br /&gt;On Error GoTo Ref_Retain_Remove_Err&lt;br /&gt;&lt;br /&gt;exclusion(1) = &amp;quot;VBA&amp;quot;&lt;br /&gt;exclusion(2) = &amp;quot;Access&amp;quot;&lt;br /&gt;exclusion(3) = &amp;quot;stdole&amp;quot;&lt;br /&gt;exclusion(4) = Application.GetOption(&amp;quot;Project Name&amp;quot;)&lt;br /&gt;‘Replace this line with your own Reference Library Name&lt;br /&gt;exclusion(5) = &amp;quot;aprRefLib&amp;quot;&lt;br /&gt;&lt;br /&gt;ref_count = Application.References.Count&lt;br /&gt;&lt;br /&gt;If ref_count &gt; 4 Then&lt;br /&gt;    ReDim Reflist(1 To ref_count)&lt;br /&gt;    i = 0&lt;br /&gt;    For Each Ref In Application.References&lt;br /&gt;       strRefName = Ref.Name&lt;br /&gt;       chk_flag = False&lt;br /&gt;       For j = 1 To 5&lt;br /&gt;          If strRefName = exclusion(j) Then&lt;br /&gt;              chk_flag = True&lt;br /&gt;              Exit For&lt;br /&gt;           End If&lt;br /&gt;        Next&lt;br /&gt;        If chk_flag = False Then&lt;br /&gt;            i = i + 1&lt;br /&gt;        'Collect the Reference Library Project Names, if any, other than&lt;br /&gt;        'the Names in the exclusion list to remove them&lt;br /&gt;        'before attaching the new ones, to avoid Project Name conflict.&lt;br /&gt;            Reflist(i) = Ref.Name&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;    ReDim Preserve Reflist(1 To i)&lt;br /&gt;'Remove the collected Reference Libraries&lt;br /&gt;    For j = 1 To i&lt;br /&gt;        Set Ref = References(Reflist(j))&lt;br /&gt;        References.Remove Ref&lt;br /&gt;    Next&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Ref_Retain_Remove = True&lt;br /&gt;&lt;br /&gt;Ref_Retain_Remove_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;Ref_Retain_Remove_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Ref_Retain_Remove()&amp;quot;&lt;br /&gt;Ref_Retain_Remove = False&lt;br /&gt;Resume Ref_Retain_Remove_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; Before closing the Database, if you would like to save a copy of the Library Database in a Compiled state you can create it by running &lt;b&gt;Tools- -&gt;Database Utilities - -&gt; Make MDE File…&lt;/b&gt; option and name the database as &lt;b&gt;MyLib.MDE&lt;/b&gt;. You may save it at the same location of the &lt;b&gt;.mdb&lt;/b&gt; file and move the &lt;b&gt;.mdb&lt;/b&gt; file to your local drive or in your private server location where access to others are forbidden.  When you add more common routines into this Library file you can recompile it and replace the earlier &lt;b&gt;.MDE&lt;/b&gt; file so that the new programs can be made available to all your Projects without making any changes in them. You can attach your Library Database &lt;b&gt;MyLib.mde&lt;/b&gt; along with others to all of your future and current running Projects. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have two programs; the second one is to validate the existing attached References and remove them except the essential ones mentioned above to avoid conflicts. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The preparations are in place and we are going to do a Trial Run. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a new Database.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the VBA Editing Window (&lt;b&gt;Alt+F11&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the Debug Window (Immediate Window) – &lt;b&gt;Ctrl+G&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Type the following line in the Debug Window and press Enter so that we can attach your own Common Library File &lt;b&gt;MyLib.mde&lt;/b&gt; and Run the main program &lt;b&gt;AddReferences()&lt;/b&gt; from there:&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; Change the Server Location address to match with your own. &lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;Application.References.AddFromFile(&amp;quot;\\hosfs03\InhouseSys\CommonLib\MyLib.mde&amp;quot;) &lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;If you select &lt;b&gt;Tools- -&gt;Reference&lt;/b&gt;; you can see that your own Library File is now attached to your Project. &lt;br /&gt;&lt;br /&gt;We can now call the &lt;b&gt;AddReferences()&lt;/b&gt; program from your Function Library from the Debug Window itself and attach other Library Files List we have created in the Text File. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Type the following line in the Debug Window and press Enter key to do that: &lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;AddReferences&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;You can now check the Reference Library List to re-confirm that all the required files are in place. In your next Project all you need to do after creating a new Database is to type the following two lines in the Debug Window and press Enter key to add all required Reference Libraries to your Project at once:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;Application.References.AddFromFile(&amp;quot;\\hosfs03\InhouseSys\CommonLib\MyLib.mde&amp;quot;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;AddReferences&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/03/ms-access-and-reference-library.shtml&amp;amp;title=MS-Access+and+Reference+Library"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button Animation-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml"&gt;Cardinal Text Format in Access&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Custom Report Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Custom Made Form Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml"&gt;Rounding Function MRound() of Excel&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-2562909303705084467?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=ho8u_Q2begI:9uPnMcqxQmQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=ho8u_Q2begI:9uPnMcqxQmQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=ho8u_Q2begI:9uPnMcqxQmQ:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=ho8u_Q2begI:9uPnMcqxQmQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=ho8u_Q2begI:9uPnMcqxQmQ:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/ho8u_Q2begI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/ho8u_Q2begI/ms-access-and-reference-library.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/03/ms-access-and-reference-library.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-1261878693124731986</guid><pubDate>Fri, 20 Mar 2009 13:57:00 +0000</pubDate><atom:updated>2009-03-20T19:33:12.946+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Inputbox and Simple Menus</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8R7Q3Lab8ApM1YhMU1dyz1OV3AM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8R7Q3Lab8ApM1YhMU1dyz1OV3AM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8R7Q3Lab8ApM1YhMU1dyz1OV3AM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8R7Q3Lab8ApM1YhMU1dyz1OV3AM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We have already learned how to create Menus and Toolbars through the following Articles:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/calendar-and-toolbars.shtml"&gt;Calendar and Toolbars&lt;/a&gt;  &lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml"&gt;Custom Menus and Toolbars&lt;/a&gt; &lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars2.shtml"&gt;Custom Menus and Toolbars-2&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I think &lt;b&gt;InputBox()&lt;/b&gt; function is one of the few things that we come across when start learning VBA and discard it later altogether when we see more exiting objects like &lt;b&gt;MsgBox()&lt;/b&gt;.  Probably its usage is not properly understood and it doesn&amp;#39;t deserve this neglect. The usage of &lt;b&gt;Inputbox()&lt;/b&gt; function is very simple like &lt;b&gt;MsgBox()&lt;/b&gt; but seldom used in programs to gather user responses.  Instead, MsgBox() is the most preferred control, which has a variety of options available to configure it with different options of Command Buttons. But these options are like &lt;b&gt;OK, Cancel, Retry, Yes, No&lt;/b&gt; etc. MsgBox cannot be programmed to make selections from user defined Options like the facility provides by InputBox().&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have learned how to use &lt;a href="http://www.msaccesstips.com/2006/09/msgbox-with-office-assistant.shtml"&gt;Office Assistant&lt;/a&gt; with preferred default Animation character instead of MsgBox. We have also seen how to collect user responses using Office Assistant with &lt;a href="http://www.msaccesstips.com/2008/02/office-assistant-with-check-box-menu.shtml"&gt;Check-Boxes&lt;/a&gt; or &lt;a href="http://www.msaccesstips.com/2008/01/msgbox-with-options-menu.shtml"&gt;Option Balloon&lt;/a&gt; Menus in them.  But, I admit that the VBA routines involved in these methods are complex and needs some time to understand the intricacies. But, once the program is in place the usage is very simple and can be inserted freely in your Code across projects, when placed in a library database and when linked to your other projects.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Coming back to the &lt;b&gt;Inputbox()&lt;/b&gt; function; let us look into a simple example in a sub-routine.  A Report &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt;&lt;/b&gt; on the &lt;b&gt;Main Switchboard&lt;/b&gt; when clicked; a small menu is displayed asking the &lt;a href="http://www.msaccesstips.com/2006/11/create-msaccess-user-account.shtml"&gt;User&lt;/a&gt; whether she would like to get &lt;b&gt;(1) Report Preview&lt;/b&gt; or &lt;b&gt;(2) Print &lt;/b&gt;the Report directly to the Printer or &lt;b&gt;(3) Exit&lt;/b&gt;, if there is a change of mind.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The simple usage of &lt;b&gt;InputBox()&lt;/b&gt; function Syntax is given below:&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;X = InputBox(&amp;quot;Message Text&amp;quot;,&amp;quot;Title&amp;quot;,Default Value)&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Title&lt;/b&gt; and &lt;b&gt;Default Values&lt;/b&gt; parameters are Optional.  There are other optional values as well. You may check for them in the Microsoft Access Help Documents. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Message Text&lt;/b&gt; is displayed on the body of the Form and the &lt;b&gt;Title&lt;/b&gt; text appears on the &lt;b&gt;Title Bar&lt;/b&gt; of the Control.  We have used &lt;b&gt;1&lt;/b&gt; as third Parameter (&lt;b&gt;Default Value&lt;/b&gt;) and that value is inserted in the &lt;b&gt;Text Box&lt;/b&gt; as shown in the following example image:&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/inputbox1-707716.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 134px;" src="http://msaccesstips.com/uploaded_images/inputbox1-707713.jpg" border="0" alt="Usage of InputBox Example" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;The Code that brings this Form up on a &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; Click &lt;i&gt;EventProcedure&lt;/i&gt; is given below.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Sub cmdRpt_Click()&lt;br /&gt;Dim varResponse as Variant&lt;br /&gt;&lt;br /&gt;varResponse = InputBox(&amp;quot;(1) Print Preview (2) Print (3) Exit&amp;quot;, &amp;quot;Select 1/2/3&amp;quot;,1)&lt;br /&gt;&lt;br /&gt;Select Case varResponse&lt;br /&gt;    Case 1&lt;br /&gt;        DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewPreview&lt;br /&gt;    Case 2&lt;br /&gt;        DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewNormal&lt;br /&gt;    Case 3&lt;br /&gt;        Exit Sub&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When the User makes a selection as per the Options provided, the selected value is tested and executes the actions programmed in the &lt;b&gt;Select Case….End Select&lt;/b&gt; statements.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; The Inputbox() function brings up a Form with its &lt;b&gt;Border Style&lt;/b&gt; Property Value set as &lt;b&gt;Dialog&lt;/b&gt; so that the &lt;b&gt;Minimize/Maximize &amp;amp; Restore&lt;/b&gt; Buttons removed from the &lt;b&gt;Title&lt;/b&gt; Bar except the &lt;b&gt;Window Close&lt;/b&gt; control. You are not allowed to click on any other &lt;b&gt;Form&lt;/b&gt; or &lt;b&gt;Objects&lt;/b&gt; in the &lt;b&gt;Application window&lt;/b&gt; before you are done with the InputBox() Function, indicating that this Form&amp;#39;s &lt;b&gt;Modal&lt;/b&gt; Property is set to &lt;b&gt;Yes&lt;/b&gt;.  We have familiarized the usage of &lt;b&gt;Pop up&lt;/b&gt; and other Property settings of the Form in our earlier discussions on Form Properties in the following Articles:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml"&gt;Forms and Custom Properties&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Synchronized Floating Pop-up Form&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/03/positioning-pop-up-forms.shtml"&gt;Positioning Pop-up Forms&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/03/change-form-modes-on-user-profile.shtml"&gt;Change Form Modes on User Profile&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;While using &lt;b&gt;Inputbox()&lt;/b&gt; this way in programs we must take care of few things to avoid some undesirable side effects and pay attention to give the Menu a better look as well.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, we will take the side effects part. We have provided Option &lt;b&gt;3&lt;/b&gt; to close the Dialog Box normally, if the &lt;a href="http://www.msaccesstips.com/2006/11/remove-users-from-security-groups.shtml"&gt;User&lt;/a&gt; has a change of mind after bringing up the Menu. But, she may ignore option &lt;b&gt;3&lt;/b&gt; in the Menu and may use the &lt;b&gt;Window Close&lt;/b&gt; control on the Title bar or click on the &lt;b&gt;Cancel&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt; instead; that can invite trouble in the Code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Since we have defined the Option Values in the Menu as Integer (&lt;b&gt;1,2&lt;/b&gt; and &lt;b&gt;3&lt;/b&gt;) naturally we will think about using an &lt;b&gt;Integer&lt;/b&gt; Type Variable to record the response of the User. But, the User may click on the &lt;b&gt;Cancel&lt;/b&gt; Command Button or &lt;b&gt;Window Close&lt;/b&gt; Title Bar control, without selecting any of the options displayed, to close the Window.  In that case the InputBox() Function will return an &lt;b&gt;Empty String (&amp;quot;&amp;quot;)&lt;/b&gt; as response. If we have defined an Integer Variable to accept the returned value, then this will end up with a &lt;b&gt;Type Mismatch&lt;/b&gt; Error and the program will crash.&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;We can use a string variable to accept the Empty string result to avoid this problem and the &lt;b&gt;Select Case….&lt;/b&gt; statement will work without modification even though we are testing for Integer values rather than in &lt;b&gt;Case &amp;quot;1&amp;quot;&lt;/b&gt; style.  A reasonable &lt;b&gt;Variable Type&lt;/b&gt; selection to record the user response in these circumstances is a &lt;b&gt;Variant&lt;/b&gt; Type that can accept any data type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With a little trick we can make the program to ignore the &lt;b&gt;Cancel&lt;/b&gt; Button and &lt;b&gt;Window Close&lt;/b&gt; Title Bar control Clicks and force the user to make a selection from the &lt;b&gt;Menu Options&lt;/b&gt; only, if she want to get out of the Menu normally.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have inserted &lt;b&gt;1&lt;/b&gt; as third &lt;b&gt;Optional Parameter&lt;/b&gt; Value to take care of the &lt;b&gt;OK&lt;/b&gt; Command Button Click by the User just in case she doesn&amp;#39;t type a selection value from the Menu Options and simply hits the &lt;b&gt;OK&lt;/b&gt; Button.  If she types one of the Option values in the Text Box and hits the &lt;b&gt;Enter&lt;/b&gt; key, as we expect her to do, that will return the value selected into the varResponse Variable and the InputBox control will close normally.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will modify the above Code:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;to make it a better looking real Menu&lt;/li&gt;&lt;br /&gt;&lt;li&gt;to ignore the &lt;b&gt;Cancel&lt;/b&gt; Command Button and &lt;b&gt;Window Close&lt;/b&gt; Title Bar control clicks.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;To prepare the Menu we will define a string Variable and write the following expression before inserting it into the InputBox() Function:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;Dim strMenu as String&lt;br /&gt;&lt;br /&gt;strMenu = &amp;quot;1. Report Preview&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;2. Print Report&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;3. Exit&amp;quot;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;We will put the InputBox() Function within a &lt;b&gt;Do While…Loop&lt;/b&gt; with a condition so that the Function will keep repeatedly executing if the user doesn&amp;#39;t make a valid selection from the Menu and discourage her from Clicking &lt;b&gt;Window Close&lt;/b&gt; or &lt;b&gt;Cancel&lt;/b&gt; Buttons to get out of the Dialog Box.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;br /&gt; varResponse = &amp;quot;&amp;quot;&lt;br /&gt; Do While Len(varResponse) = 0 Or varResponse &amp;lt; 1 Or varResponse &amp;gt; 3&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;varResponse = InputBox(strMenu, &amp;quot;Select 1/2/3&amp;quot;,1)&lt;br /&gt; Loop&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;After the above changes the Menu will look like the following image:&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/inputbox2-744782.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 134px;" src="http://msaccesstips.com/uploaded_images/inputbox2-744778.jpg" border="0" alt="With Property Formed Menu Options" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;The modified Code is given below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;Private Sub cmdRpt_Click()&lt;br /&gt;‘------------------------------------------------------------&lt;br /&gt;‘Author : a.p.r. pillai&lt;br /&gt;‘Date : March-2009&lt;br /&gt;‘URL  : www.msaccesstips.com&lt;br /&gt;‘All Rights Reserved by www.msaccesstips.com&lt;br /&gt;‘------------------------------------------------------------&lt;br /&gt;Dim varResponse As Variant&lt;br /&gt;Dim strMenu As String&lt;br /&gt;&lt;br /&gt;strMenu = &amp;quot;1. Report Preview&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;2. Print Report&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;3. Exit&amp;quot;&lt;br /&gt;&lt;br /&gt;varResponse = &amp;quot;&amp;quot;&lt;br /&gt;Do While Len(varResponse) = 0 Or varResponse &amp;lt; 1 Or varResponse &amp;gt; 3&lt;br /&gt;    varResponse = InputBox(strMenu, &amp;quot;Select 1/2/3&amp;quot;, 1)&lt;br /&gt;Loop&lt;br /&gt;&lt;br /&gt;Select Case varResponse&lt;br /&gt;    Case 1&lt;br /&gt;        DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewPreview&lt;br /&gt;    Case 2&lt;br /&gt;        DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewNormal&lt;br /&gt;    Case 3&lt;br /&gt;        Exit Sub&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Probably the next question comes into one&amp;#39;s mind is, do we have to use the Menu Options always in the form &lt;b&gt;1,2,3&lt;/b&gt; etc., can we use alphabets instead, like &lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;R. Report Preview&lt;br /&gt;P. Print Report&lt;br /&gt;E. Exit ?&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/inputbox3-781894.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 134px;" src="http://msaccesstips.com/uploaded_images/inputbox3-781891.jpg" border="0" alt="Alphabet as Menu Options" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;Yes, we can with few changes in the Code as given below:&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;br /&gt;strMenu = &amp;quot;R. Report Preview&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;P. Print Report&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;E. Exit&amp;quot;&lt;br /&gt;&lt;br /&gt;varResponse= &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Do While instr(1, &amp;quot;RPE&amp;quot;,varResponse)=0 or len(varResponse)=0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;varResponse = InputBox(strMenu, &amp;quot;Select R/P/E&amp;quot;, &amp;quot;R&amp;quot;)&lt;br /&gt;Loop&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Select Case…&lt;/b&gt; statement must be changed to:&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;Select Case varResponse&lt;br /&gt;    Case &amp;quot;R&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewPreview&lt;br /&gt;    Case &amp;quot;P&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewNormal&lt;br /&gt;    Case &amp;quot;E&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exit Sub&lt;br /&gt;End Select&lt;br /&gt;&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The changed Code with alphabets as Options is given below:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Sub cmdRpt_Click()&lt;br /&gt;‘------------------------------------------------------------&lt;br /&gt;‘Author : a.p.r. pillai&lt;br /&gt;‘Date : March-2009&lt;br /&gt;‘URL  : www.msaccesstips.com&lt;br /&gt;‘All Rights Reserved by www.msaccesstips.com&lt;br /&gt;‘------------------------------------------------------------&lt;br /&gt;Dim varResponse As Variant&lt;br /&gt;Dim strMenu As String&lt;br /&gt;&lt;br /&gt;strMenu = &amp;quot;R. Report Preview&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;P. Print Report&amp;quot; &amp;amp; vbCr &amp;amp; vbCr&lt;br /&gt;strMenu = strMenu &amp;amp; &amp;quot;E. Exit&amp;quot;&lt;br /&gt;&lt;br /&gt;varResponse = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Do While InStr(1, &amp;quot;RPE&amp;quot;, varResponse) = 0 Or Len(varResponse) = 0&lt;br /&gt;    varResponse = InputBox(strMenu, &amp;quot;Select R/P/E&amp;quot;, &amp;quot;R&amp;quot;)&lt;br /&gt;Loop&lt;br /&gt;&lt;br /&gt;Select Case varResponse&lt;br /&gt;    Case &amp;quot;R&amp;quot;&lt;br /&gt;        DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewPreview&lt;br /&gt;    Case &amp;quot;P&amp;quot;&lt;br /&gt;        DoCmd.OpenReport &amp;quot;Orders&amp;quot;, acViewNormal&lt;br /&gt;    Case &amp;quot;E&amp;quot;&lt;br /&gt;        Exit Sub&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/03/inputbox-and-simple-menus.shtml&amp;amp;title=InputBox+and+Simple+Menus"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml"&gt;Cardinal Text Format in Access&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Custom Report Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Custom Made Form Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml"&gt;Rounding Function MRound() of Excel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Custom Calculator and Eval() Function&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-1261878693124731986?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=zD1PnvYQghM:1VxhEihar88:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=zD1PnvYQghM:1VxhEihar88:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=zD1PnvYQghM:1VxhEihar88:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=zD1PnvYQghM:1VxhEihar88:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=zD1PnvYQghM:1VxhEihar88:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/zD1PnvYQghM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/zD1PnvYQghM/inputbox-and-simple-menus.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/03/inputbox-and-simple-menus.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-4326772045108734196</guid><pubDate>Fri, 13 Mar 2009 09:30:00 +0000</pubDate><atom:updated>2009-03-13T15:36:19.666+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Change Form Modes on User Profile</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/JOuUerwwVgnEfsO8IRhg0yD_GYo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JOuUerwwVgnEfsO8IRhg0yD_GYo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/JOuUerwwVgnEfsO8IRhg0yD_GYo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JOuUerwwVgnEfsO8IRhg0yD_GYo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We have seen how to define a &lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Pop up&lt;/a&gt; Form and how it can be made to appear on a particular &lt;a href="http://www.msaccesstips.com/2009/03/positioning-pop-up-forms.shtml"&gt;position&lt;/a&gt; on the Application window, when it is opened. We have also seen that the Form behavior is controlled by setting or modifying the &lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Property&lt;/a&gt; values of the Form. In those cases we have changed the Form&amp;#39;s &lt;b&gt;Pop up, Border Style&lt;/b&gt; and &lt;b&gt;Auto Center&lt;/b&gt; Property Values manually during design time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here, we will try something different and will attempt to change the Form opening Modes (&lt;b&gt;Data Entry Mode&lt;/b&gt; or &lt;b&gt;Edit/Search Mode&lt;/b&gt;) at run time automatically based on the identity of the Current User of the Form.  When the Database is shared on a &lt;a href="http://www.msaccesstips.com/2008/03/sending-alerts-to-workstations.shtml"&gt;Network&lt;/a&gt; the same Form can be opened by different Users and the &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Form&lt;/a&gt; should behave differently for each &lt;a href="http://www.msaccesstips.com/2006/11/create-msaccess-user-account.shtml"&gt;User&lt;/a&gt; or Users Group. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For Example, a single Form can be used for &lt;b&gt;Data Entry&lt;/b&gt; by one group of Users, who are allowed only to key-in new records and others are allowed to View, Edit and Search but not allowed to add new records. Data Entry User can also edit data that he/she keys-in during the current data entry session.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Open Mode change can be done by checking the Security User Account or &lt;a href="http://www.msaccesstips.com/2006/11/msaccess-security-group-account.shtml"&gt;Group Account&lt;/a&gt; name of the Current User and by changing the &lt;b&gt;Data Entry, Allow Additions&lt;/b&gt; Property Values.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We need a small VBA program to check the Current User&amp;#39s Group Account information to determine whether he/she belongs to the &lt;i&gt;DATAENTRY&lt;/i&gt; Group Account or not (the User Workgroup name &lt;i&gt;DATAENTRY&lt;/i&gt; is used here as an example only). Accordingly the program will set the &lt;b&gt;Mode&lt;/b&gt; of the Form for the current session. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The VBA Routine is given below: &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function ChangeFormMode(ByVal strFormName As String, ByVal UserGroupName As String)&lt;br /&gt;'----------------------------------------------&lt;br /&gt;'Author : a.p.r. pillai&lt;br /&gt;'Date   : Feb-2009&lt;br /&gt;'All Right Reserved by www.msaccesstips.com&lt;br /&gt;'----------------------------------------------&lt;br /&gt;Dim wsp As Workspace, strUser As String&lt;br /&gt;Dim j As Integer, frm As Form&lt;br /&gt;Dim chkFlag As Boolean, GrpCount As Integer&lt;br /&gt;&lt;br /&gt;On Error GoTo ChangeFormMode_Err&lt;br /&gt;&lt;br /&gt;Set frm = Forms(strFormName)&lt;br /&gt;strUser = CurrentUser&lt;br /&gt;Set wsp = DBEngine.Workspaces(0)&lt;br /&gt;GrpCount = wsp.Users(strUser).Groups.Count&lt;br /&gt;'checks whether 'DATAENTRY' Group Name is present&lt;br /&gt;'within the User's Group Account Names.&lt;br /&gt;chkFlag = False&lt;br /&gt;For j = 0 To GrpCount - 1&lt;br /&gt;    If wsp.Users(strUser).Groups(j).Name = UserGroupName Then&lt;br /&gt;        chkFlag = True&lt;br /&gt;        Exit For&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;If chkFlag Then&lt;br /&gt;    frm.DataEntry = True&lt;br /&gt;    frm.AllowAdditions = True&lt;br /&gt;Else&lt;br /&gt;    frm.DataEntry = False&lt;br /&gt;    frm.AllowAdditions = False&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;ChangeFormMode_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;ChangeFormMode_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;ChangeFormMode&amp;quot;&lt;br /&gt;Resume ChangeFormMode_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Copy and Paste the above program into a Global Module (Standard Module) in your database and save it. The program is called from the &lt;b&gt;Form_Load()&lt;/b&gt; &lt;i&gt;EventProcedure&lt;/i&gt; of the Form with the &lt;b&gt;Form Name&lt;/b&gt; and the &lt;b&gt;User Group Account&lt;/b&gt; name as parameters as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;   ChangeFormMode Me.Name, &amp;quot;DataEntry&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;A security &lt;b&gt;User Account&lt;/b&gt; may belong to one or more security &lt;b&gt;Group Accounts&lt;/b&gt; besides the default &lt;b&gt;Users&lt;/b&gt; Group Account, which all the Users belong.  Therefore, we need to check through the User&amp;#39;s Security Group Account list, whether he/she belongs to the &lt;b&gt;DataEntry&lt;/b&gt; Group or not and if found then change the Form&amp;#39;s open Mode accordingly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note: &lt;/b&gt; This method to work, the Database must be secured by implementing MS-Access Security and assume that the Users are grouped under different Work Groups like &lt;b&gt;Data Entry Group, Team Leaders Groupb&lt;/b&gt; or &lt;b&gt;Managers Group&lt;/b&gt; and so on. To learn more about &lt;a href="http://www.msaccesstips.com/2006/11/microsoft-access-security.shtml"&gt;Microsoft Access Security&lt;/a&gt; visit the pages under &lt;b&gt;Security&lt;/b&gt; in the Main Menu.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If your machine is not configured to use a common MS-Access Work Group Information file or if you have not implemented MS-Access Security using the local Work Group Information File then you are automatically log-in using the default User Account &lt;b&gt;Admin&lt;/b&gt;, a member of the &lt;b&gt;Admins&lt;/b&gt; and &lt;b&gt;Users&lt;/b&gt; Group.  This is happening silently and you are not asked to enter a UserID or Password. In that case you can try this procedure by passing the &lt;b&gt;Admins&lt;/b&gt; or &lt;b&gt;Users&lt;/b&gt; work group name as parameter to the above Program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But, if all Users need both features inter-changeably at their will then this can be implemented with the use of a &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; on the Form.  Since, this procedure is manually controlled, requirement of checking the Security User Account or Group Accounts doesn&amp;#39;t arise.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;All we need is a &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt; at the Footer of the Form, set with specific &lt;b&gt;Caption&lt;/b&gt; Value which can be checked and changed on every Click on the Command Button and switch the &lt;i&gt;Form Mode&lt;/i&gt; to Data Entry or Normal.&lt;br /&gt;&lt;br /&gt;Assume that the Form Opens in &lt;b&gt;Edit/Search&lt;/b&gt; Mode by setting the following Property Values at design time:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class = "colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Data Entry = False&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Additions = False&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Caption&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt; will be set as &lt;b&gt;Data Entry&lt;/b&gt; indicating that if the User wishes to change the Form into Data Entry Mode then she may click on the Command Button. Since, the same Command Button click is needed to switch the Form into one of these two Modes we must check the Caption of the Command Button to determine what is the User&amp;#39;s intention.   She may click on the Command Button repeatedly too.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;On every click we must check the Caption Value and change the Mode of the Form as well as the Caption of the Command Button to &lt;b&gt;Edit/Search&lt;/b&gt; or &lt;b&gt;Data Entry&lt;/b&gt; interchangeably.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can implement this with few lines of Code on the Form&amp;#39;s Class Module itself. The Command Button&amp;#39;s &lt;b&gt;Name&lt;/b&gt; Property Value is &lt;b&gt;cmdEdit&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Sub cmdEdit_Click()&lt;br /&gt;If Me.cmdEdit.Caption = &amp;quot;Data Entry&amp;quot; Then&lt;br /&gt;     Me.cmdEdit.Caption = &amp;quot;Edit/Search&amp;quot;&lt;br /&gt;     Me.DataEntry = True&lt;br /&gt;     Me.AllowAdditions = True &lt;br /&gt;Else&lt;br /&gt;     Me.cmdEdit.Caption = &amp;quot;Data Entry&amp;quot;&lt;br /&gt;     Me.DataEntry = False&lt;br /&gt;     Me.AllowAdditions = False&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above technique we have used for a different &lt;a href="http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml"&gt;function&lt;/a&gt; on a Form and you may take a look at that Article with the Title: &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Double Action Command Button&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/03/change-form-modes-on-user-profile.shtml&lt;br /&gt;&amp;title=Change+Form+Modes+on+User+Profile"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Custom Report Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Custom Made Form Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml"&gt;Rounding Function MRound() of Excel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Custom Calculator and Eval() Function&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/data-editing-and-security-issues.shtml"&gt;Data Editing and Security Issues&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-4326772045108734196?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=lSdLkHSnX6k:UKvJKXccnaE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=lSdLkHSnX6k:UKvJKXccnaE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=lSdLkHSnX6k:UKvJKXccnaE:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=lSdLkHSnX6k:UKvJKXccnaE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=lSdLkHSnX6k:UKvJKXccnaE:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/lSdLkHSnX6k" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/lSdLkHSnX6k/change-form-modes-on-user-profile.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/03/change-form-modes-on-user-profile.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-2475319071175688813</guid><pubDate>Fri, 06 Mar 2009 14:44:00 +0000</pubDate><atom:updated>2009-03-06T19:40:02.758+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Positioning Pop Up Forms</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/bZIu4c-iKgZFoZNsedqplzpPJRk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/bZIu4c-iKgZFoZNsedqplzpPJRk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/bZIu4c-iKgZFoZNsedqplzpPJRk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/bZIu4c-iKgZFoZNsedqplzpPJRk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We have seen the &lt;b&gt;Pop up&lt;/b&gt; form in action last week in an Article with the Title: &lt;a href="http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml"&gt;Synchronized Floating Pop up Form&lt;/a&gt; and I hope you have downloaded the Demo Database as well.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I know, I don&amp;#39;t have to talk at length about &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Forms&lt;/a&gt; and their importance in a &lt;a href="http://www.msaccesstips.com/2008/08/database-connection-string-properties.shtml"&gt;database&lt;/a&gt;, because that is the first piece of object we would like to lay our hands on, the moment we decide to start learning MS-Access and wants to put all kinds of fancy objects all over the Form.  MS-Access &lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Forms&lt;/a&gt; are far better than Forms designed in Visual Basic.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;There was an interesting incident in our office long back.  A Visual Basic Application developed by our Computer Department was installed in one of my colleague&amp;#39;s machine.  My friend got a brief introduction from the developer before he left the scene. My friend started exploring the new Application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I was sitting few workstations away from him and after about half an hour he called me and asked for some help. I was also very curious to have a look at the new Application.  When I set my eyes on the screen I realized why he called me and he confirmed that too. I couldn&amp;#39;t resist a smile on my face and pat myself on my back for working with MS-Access &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Forms&lt;/a&gt;, even though I knew VB can do many things, which you cannot do in Access.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Few years ago most of the Computer Monitors were used with 640 x 480 Resolution and the Users preferred to maintain this way because &lt;b&gt;dBase&lt;/b&gt; and &lt;b&gt;Foxprow 2.5/3.0&lt;/b&gt; based Applications were also running on their machines.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The VB Application&amp;#39;s &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;&lt;b&gt;Main Switchboard&lt;/b&gt;&lt;/a&gt; Form overlaps on all four sides of the Screen on my colleague&amp;#39;s machine and some of the Objects like &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Buttons&lt;/a&gt; and &lt;b&gt;Option Group&lt;/b&gt; etc. at the edges of the Form are only partially visible on the screen.  The Form was designed on a machine with a higher resolution without knowing where he is going to install it and ended up this way.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As far as I know, VB Form doesn&amp;#39;t have any Control Buttons (&lt;b&gt;Min/Max, Restore&lt;/b&gt; and &lt;b&gt;Close&lt;/b&gt;) on the Title Bar; no sizing handles, no Header/Footer Sections or able to define Pages and it looked like an oversize wooden board placed behind the screen frame.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I really felt few inches taller when positive remarks came from the Users of my MS-Access Databases.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Coming back to the point, we can change the behavior of the Form by setting its &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Values and we have seen several of them through earlier examples. We have set the &lt;b&gt;Pop up&lt;/b&gt; Property Value to &lt;b&gt;Yes&lt;/b&gt; in the previous Article to position the &lt;b&gt;EmployeeSub&lt;/b&gt; Form above all other Forms.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When the &lt;a href="http://www.msaccesstips.com/2008/06/database-open-close-event-alerts.shtml"&gt;Database&lt;/a&gt; Window is in &lt;b&gt;maximized&lt;/b&gt; state if you open a normal Form it will also adjust itself to the maximized state.  But, if the &lt;b&gt;Pop up&lt;/b&gt; Property value is set to &lt;b&gt;Yes&lt;/b&gt; then the form will open in its original designed size.  This is true if you set the &lt;b&gt;Border Style&lt;/b&gt; Property value to &lt;b&gt;Dialog&lt;/b&gt; or &lt;b&gt;Thin&lt;/b&gt; instead of setting the Pop up Property value.  But, this will remove the &lt;b&gt;Minimize/Maximize&lt;/b&gt;; &lt;b&gt;Restore&lt;/b&gt; Window Buttons on the &lt;b&gt;Title Bar&lt;/b&gt;.  Setting the &lt;b&gt;Border Style&lt;/b&gt; property value to &lt;b&gt;None&lt;/b&gt; will remove the Title Bar totally.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It is a well known fact that all MS-Access Objects like Forms/Reports opens and stays within the MS-Access Application Window.  You cannot take any of them out of the Application Window boundaries, right?&lt;br /&gt;&lt;br /&gt;Wrong, you can, try this to find out: &lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;If the Access Application Window is in &lt;b&gt;maximized&lt;/b&gt; state then click the &lt;b&gt;Restore Down&lt;/b&gt; control button (the middle one between &lt;b&gt;minimize/maximize&lt;/b&gt; and &lt;b&gt;close&lt;/b&gt; buttons) on the &lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Title bar&lt;/a&gt; and you will find a Window sizing control at the right bottom corner of the Application window.  When you place the mouse pointer there it will change into a double-headed arrow. Click and drag the corner up, moving the mouse towards left top corner direction of the screen, so that the MS-Access Application Window reduces to about half of its size or make it even smaller. But you must be able to see one of your Pop up Forms in the database window and you are going to open it next.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open one of your Pop up Forms and you will see that it jumps out of the Application Window.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;If you didn&amp;#39;t make the Application window small enough then click on the Title Bar of the Pop up Form and drag it out of the Application Window. You can place both the Pop up Form and Application Window side by side or place the Pop up Form over the small Application window to hide it completely.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Don&amp;#39;t attempt to minimize the MS-Access Application Window, if you do then the Pop up Form will jump in and hide. If the Application window is very small then the Pop up Form may open over the Application window hiding it completely.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/popupout-791491.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 296px;" src="http://msaccesstips.com/uploaded_images/popupout-791487.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;Forms have another Property &lt;b&gt;Auto Center&lt;/b&gt;. Usually this property is set to &lt;b&gt;Yes&lt;/b&gt; along with the &lt;b&gt;Pop up&lt;/b&gt; Property settings to make the Form to appear in the middle of the Application Window.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But, what do we do if we want the Pop up Form to appear in the top right corner or right bottom corner or any place other than the center of the Screen?  There are no Property settings to make this happen. But there is a simple way to get this done, try the following method:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Maximize the Application Window.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open a Pop up Form in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the Form (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Properties&lt;/b&gt;) and see that the &lt;b&gt;Auto Center&lt;/b&gt; property is set to &lt;b&gt;No&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If the Form&amp;#39;s design frame is larger than the actual design size then reduce the design frame size by dragging the right bottom corner to the desired size.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Title Bar of the Form and drag it to the right top corner (or any other position you prefer) and place it there.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Save&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml"&gt;Toolbar Button&lt;/a&gt; or select &lt;b&gt;Save&lt;/b&gt; from &lt;b&gt;File&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Close the &lt;b&gt;Design view&lt;/b&gt; of the Form&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Now, Open the Form in Normal View. The Form will appear where you have placed and saved it in design view.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Tip:&lt;/b&gt; This works not only for Pop up Forms, works on any Form.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/03/positioning-pop-up-forms.shtml&amp;title=Positioning+Pop up+Forms"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Custom Made Form Wizard&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml"&gt;Rounding Function MRound() of Excel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Custom Calculator and Eval() Function&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/data-editing-and-security-issues.shtml"&gt;Data Editing and Security Issues&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Event Trapping &amp; Summary on Datasheet&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-2475319071175688813?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=kWnPoa_dxkk:LodbPXKuBaY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=kWnPoa_dxkk:LodbPXKuBaY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=kWnPoa_dxkk:LodbPXKuBaY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=kWnPoa_dxkk:LodbPXKuBaY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=kWnPoa_dxkk:LodbPXKuBaY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/kWnPoa_dxkk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/kWnPoa_dxkk/positioning-pop-up-forms.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/03/positioning-pop-up-forms.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-9070659452023969059</guid><pubDate>Fri, 27 Feb 2009 16:52:00 +0000</pubDate><atom:updated>2009-02-27T22:51:55.057+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Synchronized Floating popup Form</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BjZNjy6MWPe-V-L_aep_hnyAdlY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BjZNjy6MWPe-V-L_aep_hnyAdlY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BjZNjy6MWPe-V-L_aep_hnyAdlY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BjZNjy6MWPe-V-L_aep_hnyAdlY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;This Form is designed specifically for inquiry purposes (not for Data Entry).  The Source Data Table has several fields and the information in them can be categorized into different groups for viewing. &lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;For example, the Employees &lt;a href="http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml"&gt;Form&lt;/a&gt;, in Northwind.mdb sample database, has been divided into two parts, viz. &lt;b&gt;Company Information&lt;/b&gt; and &lt;b&gt;Personal Information&lt;/b&gt;.   The &lt;b&gt;Company Info&lt;/b&gt; part is designed on the first Page of a &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-menu-design.shtml"&gt;Tab Control&lt;/a&gt; and the second part &lt;b&gt;Personal Info&lt;/b&gt; category of fields are placed on second page of the Tab Control and stays hidden till it receives a click on the second page of the Tab Control, to bring the data into view.  Let us assume that the &lt;b&gt;Company Info&lt;/b&gt; is the most frequently viewed or updated information and it is kept in full view and &lt;b&gt;Personal Info&lt;/b&gt; kept behind because it is not so often viewed or updated. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will design them differently with an interesting trick involving two separate stand alone Forms without linking them as Main Form and Sub-Form.  &lt;b&gt;Company Info&lt;/b&gt; on one Form and &lt;b&gt;Personal Info&lt;/b&gt; on a separate Form but both will have source data from Employees Table. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Let us name them as &lt;font class="colrgreen"&gt; &lt;b&gt;EmployeeMain&lt;/b&gt;&lt;/font&gt; and &lt;font class="colrgreen"&gt; &lt;b&gt;EmployeeSub&lt;/b&gt;&lt;/font&gt; Forms. They will remain as two independent Forms.  A sample image of both Forms in running mode is given below: &lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/synchroform-718480.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 251px;" src="http://msaccesstips.com/uploaded_images/synchroform-718057.jpg" border="0" alt="Sample Run Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;The trick is that when we open the &lt;b&gt;EmployeeMain&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/06/startup-screen-design.shtml"&gt;Form&lt;/a&gt; it will show only the &lt;b&gt;Company Info&lt;/b&gt; alone (no trick here). We will move few records forward using the &lt;b&gt;Record Navigation Button&lt;/b&gt; and at this point we would like to see the &lt;b&gt;Personal Info&lt;/b&gt; part of the current record.  We will click on a &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt; to open the &lt;b&gt;EmployeeSub&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Form&lt;/a&gt; with the &lt;b&gt;Personal Info&lt;/b&gt; of the current record on the &lt;b&gt;EmployeeMain&lt;/b&gt; Form. From this point onwards the records on both Forms move forward/back synchronized, when you move to &lt;b&gt;Next&lt;/b&gt; or &lt;b&gt;Previous&lt;/b&gt; records on the &lt;b&gt;EmployeeMain&lt;/b&gt; Form, even though they are two separate Forms. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;EmployeeSub&lt;/b&gt; Form is defined as a &lt;a href="http://www.msaccesstips.com/2007/09/reminder-popups.shtml"&gt;Pop Up&lt;/a&gt; Form (or its &lt;b&gt;Pop up&lt;/b&gt; Property value is set to &lt;b&gt;Yes&lt;/b&gt;) to float it above the EmployeeMain Form or any other Form open in the Application Window, provided if you don&amp;#39;t open another Pop Up Form. If you don&amp;#39;t want the &lt;b&gt;EmployeeSub&lt;/b&gt; Form to stay on you may close it and open again when needed using the &lt;b&gt;Personal Info&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt; on the &lt;b&gt;EmployeeMain&lt;/b&gt; Form.  When you close the &lt;b&gt;EmployeeMain&lt;/b&gt; Form this action will close the &lt;b&gt;EmployeeSub&lt;/b&gt; Form too, if it is running. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;We can very easily design these two Forms by importing the &lt;b&gt;Employees&lt;/b&gt; Table and &lt;b&gt;Employees&lt;/b&gt; Form from &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb&lt;/font&gt; Database.  If you have not used these Objects so far for any other examples given on this site you may import them into your database now.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;b&gt;Employees&lt;/b&gt; Form in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Form and drag the mouse over all Controls on the &lt;b&gt;Company Info&lt;/b&gt; Tab except the Photo (if you want it you may select that too) and the &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; controls.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Copy&lt;/b&gt; from &lt;b&gt;Edit&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Employees Table and select &lt;b&gt;Form&lt;/b&gt; from &lt;b&gt;Insert&lt;/b&gt; menu and select &lt;b&gt;Design View&lt;/b&gt; from the list of options displayed, to create a new Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Detail Section&lt;/b&gt; of the Form and select &lt;b&gt;Paste&lt;/b&gt; from &lt;b&gt;Edit&lt;/b&gt; Menu to place the copied fields of Employees Form on to the new Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If the &lt;b&gt;Form Header/Footer&lt;/b&gt; Sections of the Form are not visible then select &lt;b&gt;Form Header/Footer&lt;/b&gt; from &lt;b&gt;View&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Text Control&lt;/a&gt; with the employee name expression from the Header Section of the &lt;b&gt;Employees&lt;/b&gt; Form to the Header Section of your Form. Change the Font Color to Red or some other Color you like.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Command Button in the Detail Section below the data fields.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display its Property Sheet (&lt;b&gt;View&lt;/b&gt;- -&gt; &lt;b&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;font class="colrgreen"&gt;cmdPersonalInfo&lt;/font&gt; and the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Personal Info&lt;/b&gt;. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NB: &lt;/b&gt; You must be careful with the names of Forms and Controls I suggest here because they are used in the Programs. If you give them differently the trick may not work as expected after completion. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a Command Button at the &lt;b&gt;Footer Section&lt;/b&gt; of the Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property value to &lt;font class="colrgreen"&gt;cmdClose&lt;/font&gt; and the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Close&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Form&amp;#39;s &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet. Click on the left top corner of the Form where a black rectangle is shown, at the intersection of the horizontal and vertical design guide (scales) meet, to select the Form&amp;#39;s Property Sheet, if it is not the current one.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Company Info&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the VBA Code Module of the Form (&lt;b&gt;Alt+F11&lt;/b&gt;). Copy and Paste the following Code into the Code Module.&lt;/li&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Option Compare Database&lt;br /&gt;Option Explicit&lt;br /&gt;Dim strSQL As String&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Sub cmdClose_Click()&lt;br /&gt;DoCmd.Close&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdPersonalInfo_Click()&lt;br /&gt;If IsLoaded(&amp;quot;EmployeesSub&amp;quot;) Then&lt;br /&gt;   strSQL = &amp;quot;SELECT Employees.* FROM Employees &amp;quot;&lt;br /&gt;   strSQL = strSQL &amp;amp; &amp;quot;WHERE ([EmployeeID] = &amp;quot; &amp;amp; Me![EmployeeID] &amp;amp; &amp;quot;);&amp;quot;&lt;br /&gt;   Forms(&amp;quot;EmployeeSub&amp;quot;).RecordSource = strSQL&lt;br /&gt;   DoCmd.SelectObject acForm, &amp;quot;EmployeeSub&amp;quot;, False&lt;br /&gt;Else&lt;br /&gt;   DoCmd.OpenForm &amp;quot;EmployeeSub&amp;quot;, acNormal, , &amp;quot;[Employeeid] = &amp;quot; &amp;amp; Me![EmployeeID], acFormReadOnly, acWindowNormal&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Forms(&amp;quot;EmployeeMain&amp;quot;).ActiveControl.SetFocus&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Close()&lt;br /&gt;    DoCmd.Close acForm, &amp;quot;EmployeeSub&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Current()&lt;br /&gt;If IsLoaded(&amp;quot;EmployeeSub&amp;quot;) Then&lt;br /&gt;   strSQL = &amp;quot;SELECT Employees.* FROM Employees &amp;quot;&lt;br /&gt;   strSQL = strSQL &amp;amp; &amp;quot;WHERE ([EmployeeID] = &amp;quot; &amp;amp; Me![EmployeeID] &amp;amp; &amp;quot;);&amp;quot;&lt;br /&gt;   Forms(&amp;quot;EmployeeSub&amp;quot;).RecordSource = strSQL&lt;br /&gt;   DoCmd.SelectObject acForm, &amp;quot;EmployeeSub&amp;quot;, False&lt;br /&gt;   Forms(&amp;quot;EmployeeMain&amp;quot;).SetFocus&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Open(Cancel As Integer)&lt;br /&gt;DoCmd.Restore&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Save the Form with the name &lt;font class="colrgreen"&gt;EmployeeMain&lt;/font&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt; Repeat the process from &lt;b&gt;Step-3&lt;/b&gt; to &lt;b&gt;Step-8&lt;/b&gt; for transferring information from the &lt;b&gt;Personal Info&lt;/b&gt; Tab of the &lt;b&gt;Employees&lt;/b&gt; Form to a new Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;b&gt;Form Header/Footer&lt;/b&gt; Section of the Form (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Form Header/Footer&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Command Button and change the &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;font class="colrgreen"&gt;cmdClose&lt;/font&gt; and the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Close&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Form&amp;#39;s Property Sheet.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values as given below:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;li&gt;Caption = Personal Info&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Default View = Single Form&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Additions = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Deletions = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Data Entry = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Record Selectors = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Navigation Buttons = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Dividing Lines = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Auto Resize = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Pop Up = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Border Style = Dialog&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Design Changes = Design View Only. &lt;/li&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;   &lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the Form (&lt;b&gt;Alt+F11&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the following Code into the Code Module.&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;Private Sub cmdClose_Click()&lt;br /&gt;     DoCmd.Close acForm, Me.Name&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Save the Form with the name &lt;font class="colrgreen"&gt;EmployeeSub&lt;/font&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;We need a small program to check whether the &lt;b&gt;EmployeeSub&lt;/b&gt; Form is in &lt;b&gt;Open&lt;/b&gt; state or not before attempting to refresh its source data and bring it in visible state. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the following Code into a Global Module (Standard Module) and save the Module:&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function IsLoaded(ByVal strFormName As String) As Boolean&lt;br /&gt;Dim j As Integer&lt;br /&gt;&lt;br /&gt;On Error GoTo IsLoaded_Err&lt;br /&gt;&lt;br /&gt;IsLoaded = False&lt;br /&gt;For j = 0 To Forms.Count - 1&lt;br /&gt;    If Forms(j).Name = strFormName Then&lt;br /&gt;       IsLoaded = True&lt;br /&gt;       Exit For&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;IsLoaded_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;IsLoaded_Err:&lt;br /&gt;IsLoaded = False&lt;br /&gt;Resume IsLoaded_Exit&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;To try out your creation, open the &lt;b&gt;EmployeeMain&lt;/b&gt; Form, click on the Record Navigation Control to advance few records forward.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Personal Info&lt;/b&gt; Command Button.  The &lt;b&gt;EmployeeSub&lt;/b&gt; Form will open up showing Personal Information pertains to the same employee on the main Form.  Check the Names of the Employee appearing on top of both forms.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Now, try advancing records on the main from forward or back with the record navigation control. You will see that the corresponding personal information on the &lt;b&gt;EmployeeSub&lt;/b&gt; Form is also moving along with the records on the main form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If you close the &lt;b&gt;EmployeeMain&lt;/b&gt; Form while the &lt;b&gt;EmployeeSub&lt;/b&gt; Form is open both will be closed.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;You may download the sample database from the Download Link given below and give it a try before you design one of your own to understand the trick: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/downloads/2009/02/SynchronizedForms2K.zip"&gt;&lt;img src="http://www.msaccesstips.com/images/zip.gif" border="0"&gt;&lt;font size="3" color="Blue"&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/font&gt; - File: &lt;font size="3" color="green"&gt;&lt;b&gt;SynchronizedForms2K.zip&lt;/b&gt;&lt;/font&gt; (Size:54.6K)&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml&amp;title=Synchronized+Floating+Popup+Form"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml"&gt;Rounding Function MRound() of Excel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Custom Calculator and Eval() Function&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/data-editing-and-security-issues.shtml"&gt;Data Editing and Security Issues&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Event Trapping &amp; Summary on Datasheet&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Sum() Min() Max() ParamArray&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-9070659452023969059?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=emzHcFt_WMg:1pVTF8q_IAI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=emzHcFt_WMg:1pVTF8q_IAI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=emzHcFt_WMg:1pVTF8q_IAI:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=emzHcFt_WMg:1pVTF8q_IAI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=emzHcFt_WMg:1pVTF8q_IAI:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/emzHcFt_WMg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/emzHcFt_WMg/synchronized-floating-popup-form.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/02/synchronized-floating-popup-form.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-8716751252007326518</guid><pubDate>Fri, 20 Feb 2009 18:23:00 +0000</pubDate><atom:updated>2009-02-20T23:29:30.322+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Forms and Custom Properties</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3FtjL6ziPT2J8vaBHnOOtvU1T-w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3FtjL6ziPT2J8vaBHnOOtvU1T-w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3FtjL6ziPT2J8vaBHnOOtvU1T-w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3FtjL6ziPT2J8vaBHnOOtvU1T-w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Searching and finding a record in a &lt;a href="http://www.msaccesstips.com/2007/12/who-is-online.shtml "&gt;Form&lt;/a&gt; is easy with &lt;b&gt;Edit - -&gt; Find (Ctrl + F)&lt;/b&gt; Option on a particular field value.  But, this will fetch only the first record even if there are more records matching the same search text.  Most of the time we need to find records that matches values in more than one field, like records of &lt;b&gt;Sales Representatives&lt;/b&gt; of Northwind Traders located in the City of &lt;b&gt;London&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;We will create a simple method to find all records of Employees Table that matches both fields (&lt;b&gt;City&lt;/b&gt; and &lt;b&gt;Title&lt;/b&gt;) and display them. If you have not imported the &lt;b&gt;Employees&lt;/b&gt; sample Table from &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office\Samples\NorthWind.mdb&lt;/font&gt; before then you may do it now. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a temporary table with the name &lt;b&gt;temp_param&lt;/b&gt; with two text fields; &lt;b&gt;City&lt;/b&gt; and &lt;b&gt;Title&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Add a single record with &lt;b&gt;City&lt;/b&gt; field value as &lt;b&gt;London&lt;/b&gt; and &lt;b&gt;Title&lt;/b&gt; field value as &lt;b&gt;Sales Representative&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design a &lt;b&gt;Main&lt;/b&gt; Form with this Table and place both Fields on the &lt;b&gt; Header Section&lt;/b&gt; of the Form.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Even better, if you create two Combo Boxes (instead of placing the above fields directly) using values from &lt;b&gt;City&lt;/b&gt; and &lt;b&gt;Title&lt;/b&gt; fields from Employees Table.  Create two Select Queries; by grouping values on these fields and use them as source for the Combo Boxes. Do that by following the steps given below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/formproperty-704102.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 250px;" src="http://msaccesstips.com/uploaded_images/formproperty-704055.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;cboCityQ&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;SELECT Employees.City&lt;br /&gt;FROM Employees&lt;br /&gt;GROUP BY Employees.City;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Copy and paste the above SQL String into a new &lt;a href="http://www.msaccesstips.com/2008/02/percentage-on-total-query.shtml"&gt;Query&lt;/a&gt;&amp;#39;s SQL editing window and save it with the name &lt;b&gt;cboCityQ&lt;/b&gt;. Create a second &lt;a href="http://www.msaccesstips.com/2008/02/union-query.shtml"&gt;Query&lt;/a&gt; with SQL string given below and save the &lt;a href="http://www.msaccesstips.com/2008/07/opening-dbase-files-directly.shtml"&gt;Query&lt;/a&gt; with the name &lt;b&gt;cboTitleQ&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;cboTitleQ&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;SELECT Employees.Title&lt;br /&gt;FROM Employees&lt;br /&gt;GROUP BY Employees.Title;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;a href="http://www.msaccesstips.com/2008/03/refresh-dependant-combo-box-contents.shtml"&gt;Combo-Box&lt;/a&gt; in the Header Section of the &lt;b&gt;Main&lt;/b&gt; Form using &lt;b&gt;cboCityQ&lt;/b&gt; as source data and select &lt;b&gt;City&lt;/b&gt; as &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Control&lt;/a&gt; Source&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create another Combo-Box using &lt;b&gt;cboTitleQ&lt;/b&gt; as source data and select &lt;b&gt;Title&lt;/b&gt; as &lt;b&gt;Control Source&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Name the &lt;b&gt;City&lt;/b&gt; field Combo-Box as &lt;b&gt;cboCity&lt;/b&gt; and &lt;b&gt;Title&lt;/b&gt; field Combo-Box as &lt;b&gt;cboTitle&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Design a &lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Datasheet Form&lt;/a&gt; on Employees Table and save the &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Form&lt;/a&gt; with the name &lt;b&gt;Employees_Sub&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Insert the &lt;b&gt;Employees_Sub&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Form&lt;/a&gt; as Sub-Form in the &lt;b&gt;Detail Section&lt;/b&gt; of the &lt;b&gt;Main&lt;/b&gt; Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;b&gt;Sub-Form&lt;/b&gt;, display the &lt;b&gt;Property Sheet&lt;/b&gt; (&lt;b&gt;View- -&gt;Properties&lt;/b&gt;) and set the following Property values as shown below:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;Link Child Fields = City;Title&lt;br /&gt;&lt;br /&gt;Link Master Fields = cboCity;cboTitle&lt;br /&gt;   &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Now you can select &lt;b&gt;City&lt;/b&gt; and &lt;b&gt;Title&lt;/b&gt; values from the Combo-Boxes and all the matching records will immediately show up in the Datasheet Sub-Form.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;b&gt;Database Sharing Issues&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If it is a single User database (or given Exclusive Access to a single User on &lt;a href="http://www.msaccesstips.com/2008/03/sending-alerts-to-workstations.shtml"&gt;Network&lt;/a&gt;) then the above method works fine and will have no issues.  But, it is different when the database is shared on a Network. Even though different instance of the &lt;b&gt;Main&lt;/b&gt; Form is used by individual User they are sharing the same Table to set different search criteria at the same time and likely to clash each other when the Main Form is refreshed and the &lt;b&gt;temp_param&lt;/b&gt; table record is updated.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A work-around to this problem is to use Unbound Text Boxes/Combo-Boxes on the &lt;b&gt;Main&lt;/b&gt; Form and not to use the &lt;b&gt;temp_param&lt;/b&gt; Table at all to store the values selected from &lt;b&gt;cboCity&lt;/b&gt; and &lt;b&gt;cboTitle&lt;/b&gt; Combo-Boxes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This will enable the Users to set the Values on the Unbound Combo-Boxes on their own instance of the Form without conflicts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This method also has some minor side effects.  When the User opens the &lt;b&gt;Main&lt;/b&gt; Form it will be empty till they enter values into the unbound Combo-Boxes.  This we can rectify to certain extend by creating two &lt;b&gt;Custom Properties&lt;/b&gt; on the &lt;b&gt;Main&lt;/b&gt; Form. Save the values from the Combo-Box controls into these custom properties when the Form closes and restore them back when the Form opens again.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Why I said '&lt;i&gt;to certain extend&lt;/i&gt;' because if several &lt;a href="http://www.msaccesstips.com/2006/11/create-msaccess-user-account.shtml"&gt;Users&lt;/a&gt; are sharing the &lt;b&gt;Main&lt;/b&gt; Form then the Custom Property values are saved by each User of the &lt;b&gt;Main&lt;/b&gt; Form (when he/she closes their instance of the Form) and will retain only the value saved last.  But all the Users who open the &lt;b&gt;Main&lt;/b&gt; form next time will be presented with the records related to the Custom Property Values saved last. But this is not a big issue because most probably next time when they open the Form they may require records for different criteria and can change it too.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To implement this method, first we must create the Custom Properties: &lt;b&gt;prpCity&lt;/b&gt; and &lt;b&gt;prpTitle&lt;/b&gt; on the &lt;b&gt;Main&lt;/b&gt; Form and save some initial values into them.  We can do this only with VBA Code. Sample Code is given below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function CustomProperty()&lt;br /&gt;Dim db As DAO.Database, doc As Document, prp As Property&lt;br /&gt;Set db = CurrentDb&lt;br /&gt;Set doc = db.Containers(&amp;quot;Forms&amp;quot;).Documents(&amp;quot;Main&amp;quot;)&lt;br /&gt;'creates the Custom Property with Name, data type and initial value&lt;br /&gt;Set prp = doc.CreateProperty(&amp;quot;prpCity&amp;quot;, dbText, &amp;quot;London&amp;quot;)&lt;br /&gt;&lt;br /&gt;'add the new Custom Property to the Properties collection of the Form Main&lt;br /&gt;'NB: This will not appear in the Property Sheet of the Form&lt;br /&gt;&lt;br /&gt;doc.Properties.Append prp&lt;br /&gt;Set prp = doc.CreateProperty(&amp;quot;prpTitle&amp;quot;, dbText, &amp;quot;Manager&amp;quot;) &lt;br /&gt;&lt;br /&gt;doc.Properties.Append prp&lt;br /&gt;doc.Properties.Refresh&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here, you can see that the reference to the &lt;b&gt;Main&lt;/b&gt; Form is addressed differently than the usual method of &lt;b&gt;Forms_Main&lt;/b&gt; or &lt;b&gt;Forms![Main] or Forms("Main") etc.&lt;/b&gt;. The &lt;b&gt;Forms&lt;/b&gt; group is addressed as Container; a member of the Containers (Tables, Forms, Reports etc.) Group and the &lt;b&gt;Main&lt;/b&gt; Form is addressed as a &lt;b&gt;Document&lt;/b&gt;, a member of the &lt;b&gt;Documents&lt;/b&gt; Group. To learn more about Containers and Documents visit the page with the Title: &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Saving Data on Forms not in Table&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Since, this is a one time exercise you can Copy the above Code into a Global Module (Standard Module) and &lt;b&gt;Run&lt;/b&gt; the Code directly by placing the Cursor in the middle of the Code and pressing &lt;b&gt;F5 (Run)&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you attempt to run the Code a second time it will show Errors indicating that the Custom Properties with the given name are already present on the Form.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The next step is to use these Properties on the &lt;b&gt;Form_Close()&lt;/b&gt; and &lt;b&gt;Form_Load()&lt;/b&gt; &lt;i&gt;EventProcedures&lt;/i&gt; to save values from the Combo-Box Controls into the Custom Properties and restore them back into the Combo-Box Controls when the Form is open.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following Code saves the Combo-Box contents into &lt;b&gt;prpCity&lt;/b&gt; and &lt;b&gt;prpTitle&lt;/b&gt; custom properties on the Main Form when the Form is closed:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Sub Form_Close()&lt;br /&gt;Dim db As Database, doc As Document, prp As Property&lt;br /&gt;&lt;br /&gt;On Error GoTo Form_Close_Err&lt;br /&gt;&lt;br /&gt;Set db = CurrentDb&lt;br /&gt;Set doc = db.Containers(&amp;quot;Forms&amp;quot;).Documents(&amp;quot;Main&amp;quot;)&lt;br /&gt;&lt;br /&gt;'Save the current values from the combo boxes into the custom properties&lt;br /&gt;doc.Properties(&amp;quot;prpCity&amp;quot;).Value = Me![cboCity]&lt;br /&gt;doc.Properties(&amp;quot;prpTitle&amp;quot;).Value = Me![cboTitle]&lt;br /&gt;&lt;br /&gt;Form_Close_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;Form_Close_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Form_Close()&amp;quot;&lt;br /&gt;Resume Form_Close_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The following Code restores the &lt;b&gt;cboCity&lt;/b&gt; and  &lt;b&gt;cboTitle&lt;/b&gt; values when the &lt;b&gt;Main&lt;/b&gt; Form opens by Users again:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;Dim db As Database, doc As Document, prp As Property&lt;br /&gt;&lt;br /&gt;On Error GoTo Form_Load_Err&lt;br /&gt;&lt;br /&gt;Set db = CurrentDb&lt;br /&gt;Set doc = db.Containers(&amp;quot;Forms&amp;quot;).Documents(&amp;quot;Main&amp;quot;)&lt;br /&gt;&lt;br /&gt;'Set the Combobox values from the Custom Property values saved earlier&lt;br /&gt;&lt;br /&gt;Me![cboCity] = doc.Properties(&amp;quot;prpCity&amp;quot;).Value&lt;br /&gt;Me![cboTitle] = doc.Properties(&amp;quot;prpTitle&amp;quot;).Value&lt;br /&gt;&lt;br /&gt;Form_Load_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;Form_Load_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Form_Load()&amp;quot;&lt;br /&gt;Resume Form_Load_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;How about positioning a particular record on the Form, which you have worked on last time, as current record when the Form opens? Click &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;here&lt;/a&gt; to find out.&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Custom Calculator and Eval() Function&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/data-editing-and-security-issues.shtml"&gt;Data Editing and Security Issues&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Event Trapping &amp; Summary on Datasheet&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Sum() Min() Max() ParamArray&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Box and Label Inner Margins&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml&lt;br /&gt;&amp;title=Forms+and+Custom+Properties"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-8716751252007326518?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1Y0daIgYmbc:UZHyKRso0eY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1Y0daIgYmbc:UZHyKRso0eY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1Y0daIgYmbc:UZHyKRso0eY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1Y0daIgYmbc:UZHyKRso0eY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1Y0daIgYmbc:UZHyKRso0eY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/1Y0daIgYmbc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/1Y0daIgYmbc/forms-and-custom-properties.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/02/forms-and-custom-properties.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-4185591023285026741</guid><pubDate>Fri, 13 Feb 2009 11:59:00 +0000</pubDate><atom:updated>2009-02-13T16:38:54.203+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>ControlTip Text and Time Delay</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/p-lHE8NW-j7hdZC7CjsdM_k9rA8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p-lHE8NW-j7hdZC7CjsdM_k9rA8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/p-lHE8NW-j7hdZC7CjsdM_k9rA8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p-lHE8NW-j7hdZC7CjsdM_k9rA8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Most of the Controls on a Form like &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Buttons&lt;/a&gt;, Labels, Text-Boxes and others have the Property &lt;b&gt;ControlTip Text&lt;/b&gt;. This can be set with a Value of up to a maximum length of 255 characters, either manually during design time or through Visual Basic. The text is displayed when the Mouse Pointer rests on the Control for a few seconds. This is useful to inform the User to do certain action, like Click or Double-Click, on the Control to run a Program or Macro attached to it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml"&gt;Toolbar&lt;/a&gt; Buttons above also have this feature programmed with the &lt;b&gt;Screen Tip&lt;/b&gt; Property Value (another name for ControlTip Text) to give clues to the User as to what the control does or what to do to use it.  For example when you point the Mouse pointer on the &lt;b&gt;Copy&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars2.shtml"&gt;Toolbar&lt;/a&gt; Button it will show &lt;b&gt;Copy (Ctrl+C)&lt;/b&gt; indicating that either Click on the Button to Copy the selected Text/Control or use &lt;b&gt;Ctrl+C&lt;/b&gt; to get the same result. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The time delay is programmed into this action assuming that the Mouse Pointer rests on the Control because the user probably doesn&amp;#39;t know what it does and needs some help to indicate what he/she should do to use it or what result one can get by using it. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here, we will concentrate on Controls on a Main Switchboard (&lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Control Screen&lt;/a&gt;), like &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Buttons&lt;/a&gt;, &lt;a href="http://www.msaccesstips.com/2008/05/selected-list-box-items-and-dynamic.shtml"&gt;List-Boxes&lt;/a&gt; and how to achieve the same result without the time delay that needs for the &lt;b&gt;ControlTip Text&lt;/b&gt; Property.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;There is another &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; named &lt;b&gt;Tag&lt;/b&gt; placed near to the &lt;b&gt;ControlTip&lt;/b&gt; Property; its function is not clearly defined and free to use, as you wish.  The value in this Property will not affect the Control in any way and will not have any side effects to other Properties either. You can write a short story into the &lt;b&gt;Tag&lt;/b&gt; Property, if you can limit your story to 2048 characters.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We are going to use this Property of different Controls on the Main Switchboard of a sample database to give clues to the User instantly what each control does or what to do (like Click or Double-Click) to run the Program or Macro attached to them. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You must select each control and display their Property Sheet(&lt;b&gt;View&lt;/b&gt; - -&gt; &lt;b&gt;Properties&lt;/b&gt;) and type the Value, you would like to display, into the &lt;b&gt;Tag&lt;/b&gt; Property. This text will appear instantly in the Label with dark background (you can use any color you like) placed at the bottom of the &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Form&lt;/a&gt; when the Mouse is moved over a Control with &lt;b&gt;Tag&lt;/b&gt; value set and programmed. &lt;br /&gt;&lt;br /&gt;An image of a sample Main SwitchBoard with the above trick is given below: &lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/tagproperty-779463.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 275px;" src="http://msaccesstips.com/uploaded_images/tagproperty-779461.jpg" border="0" alt="Sample Main SwitchBoard Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;A Label with dark background (let us call it &lt;b&gt;LBLTIP&lt;/b&gt;) is placed at the bottom of the design to display the clues when the Mouse moves over the controls above. The example text displayed on the image is attached to the &lt;b&gt;Tag&lt;/b&gt; Property of the &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/05/list-box-and-date-part-one.shtml"&gt;List-Box&lt;/a&gt;&lt;/b&gt; with &lt;a href="http://www.msaccesstips.com/2008/01/progress-bar-on-form.shtml"&gt;Forms&lt;/a&gt;&amp;#39; Names. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To display the clue and to remove it when the &lt;b&gt;Mouse&lt;/b&gt; moves out of the Control we need to run few lines of VBA Code at two places. &lt;b&gt;On Mouse Move&lt;/b&gt; &lt;i&gt;Event Procedure&lt;/i&gt; of the Control as well as at the &lt;b&gt;Detail Section&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2007/08/edit-data-in-zoom-in-control.shtml"&gt;Form&lt;/a&gt; to remove the text and replace it with some general message text. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The sample Code in the &lt;b&gt;On Mouse Move&lt;/b&gt; Event Procedure of the &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Reports&lt;/a&gt;&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; is given below that displays: &lt;b&gt;Open Report SwitchBoard&lt;/b&gt; in the &lt;b&gt;LBLTIP&lt;/b&gt; label below, when the Mouse is moved over the Command Button. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub cmdRpt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)&lt;br /&gt;If Me.LBLTIP.Caption &amp;lt;&amp;gt; Me.cmdRpt.Tag Then&lt;br /&gt;    Me.LBLTIP.Caption = Me.cmdRpt.Tag&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When the Mouse moves out of the &lt;a href="http://www.msaccesstips.com/2006/09/command-button-animation.shtml"&gt;Command Button&lt;/a&gt; and touches the empty area of the Detail Section of the &lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Form&lt;/a&gt; the &lt;b&gt;LBLTIP&lt;/b&gt; Caption changes to &lt;b&gt;Welcome User: Admin&lt;/b&gt; (the current MS-Access &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2006/11/create-msaccess-user-account.shtml"&gt;User Account&lt;/a&gt;&lt;/b&gt; name) appears and stays there till the mouse moves over another Control on the Form. &lt;br /&gt;&lt;br /&gt;The VBA Code in the Detail Section &lt;b&gt;On Mouse Move&lt;/b&gt; &lt;i&gt;Event Procedure&lt;/i&gt; is given below: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)&lt;br /&gt;Dim strtag As String&lt;br /&gt;strtag = &amp;quot;Welcom User: &amp;quot; &amp;amp; CurrentUser&lt;br /&gt;If Me.LBLTIP.Caption &amp;lt;&amp;gt; strtag Then&lt;br /&gt;    Me.LBLTIP.Caption = strtag&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Even though the &lt;b&gt;Detail Section&lt;/b&gt; Mouse Move Event Procedure Code has no change; repeating all three lines of code for each control is excess work. The &lt;b&gt;IF…Then&lt;/b&gt; statement is used to test and prevent setting the &lt;b&gt;LBLTIP&lt;/b&gt; Caption value repeatedly. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We can implement this with a single line of code, if we write a common routine and place it in a Global Module (standard Module) and call it with a single line of code with necessary Parameters. Such a Function is given below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Copy the following VBA Code and save it in a Standard Module: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function ControlTip(ByVal frmName As String, Optional strtext As String = &amp;quot;Welcome User: &amp;quot;, Optional xswitch As Integer = 0)&lt;br /&gt;On Error GoTo ControlTip_Err&lt;br /&gt;With Forms(frmName).Controls(&amp;quot;lblTip&amp;quot;)&lt;br /&gt;    Select Case xswitch&lt;br /&gt;        Case 1&lt;br /&gt;            If .Caption &amp;lt;&amp;gt; strtext Then&lt;br /&gt;                .Caption = strtext&lt;br /&gt;            End If&lt;br /&gt;        Case Else&lt;br /&gt;            If .Caption &amp;lt;&amp;gt; strtext Then&lt;br /&gt;                .Caption = strtext &amp;amp; CurrentUser&lt;br /&gt;            End If&lt;br /&gt;    End Select&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;ControlTip_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;ControlTip_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;ControlTip()&amp;quot;&lt;br /&gt;Resume ControlTip_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;Function&lt;/a&gt; has three Parameters: &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Name of the Form from where the Function is called.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The &lt;b&gt;LBLTIP.Caption&lt;/b&gt; text to display.  This will be taken from the &lt;b&gt;Tag&lt;/b&gt; Property Value of the Control. This parameter is defined as &lt;b&gt;Optional&lt;/b&gt; so that this can be called without a value at Form-level (in our example from Detail Section) to display the welcome message after removing the earlier contents.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The &lt;b&gt;Optional xswitch&lt;/b&gt; parameter is used for display control. Value of &lt;b&gt;1&lt;/b&gt; will display the Text value passed through the Second Parameter or else it will display a welcome message to the active User replacing earlier text in the &lt;b&gt;LBLTIP&lt;/b&gt; control.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;With the above Function we can simplify the first two Sub-Routines as given below: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub cmdRpt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)&lt;br /&gt;     ControlTip Me.Name, Me. cmdRpt.Tag, 1&lt;br /&gt;End Sub&lt;br /&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt;Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)&lt;br /&gt;    ControlTip Me.Name&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can download the sample database (Access2000 Version) from the Link below and try it out. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--Access Download Link Code--&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/downloads/2009/02/ControlTip2K.zip"&gt;&lt;img src="http://www.msaccesstips.com/images/zip.gif" border="0"&gt;&lt;font size="3" color="Blue"&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/font&gt; - File: &lt;font size="3" color="green"&gt;&lt;b&gt; ControlTip2K.zip&lt;/b&gt;&lt;/font&gt; (Size:82.4K)&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;!--End of Download Link Code--&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml&amp;title=ControlTip+Text+and+Time+Delay"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/data-editing-and-security-issues.shtml"&gt;Data Editing and Security Issues&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Event Trapping &amp; Summary on Datasheet&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Sum() Min() Max() ParamArray&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Box and Label Inner Margins&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Multiple Parameters for Query&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-4185591023285026741?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=GLRGR4UOKtI:t1VyXXdgaeY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=GLRGR4UOKtI:t1VyXXdgaeY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=GLRGR4UOKtI:t1VyXXdgaeY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=GLRGR4UOKtI:t1VyXXdgaeY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=GLRGR4UOKtI:t1VyXXdgaeY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/GLRGR4UOKtI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/GLRGR4UOKtI/controltip-text-and-time-delay.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/02/controltip-text-and-time-delay.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5796149844214073284</guid><pubDate>Fri, 06 Feb 2009 19:42:00 +0000</pubDate><atom:updated>2009-02-07T09:15:43.479+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>External Files List in Hyperlinks</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zdHaHH3A8bUVkPQSjW_4faXpR60/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zdHaHH3A8bUVkPQSjW_4faXpR60/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zdHaHH3A8bUVkPQSjW_4faXpR60/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zdHaHH3A8bUVkPQSjW_4faXpR60/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Is it possible to display a directory listing of &lt;b&gt;External Files&lt;/b&gt; on a Form and open them in their parent applications?  Several queries of different kind received through E-mails pointing towards this objective, from Readers of the earlier Article; &lt;a href="http://www.msaccesstips.com/2006/10/file-browser-in-msaccess.shtml"&gt;File Brower in MS-Access&lt;/a&gt; (Common Dialog Control).&lt;br&gt; &lt;br /&gt;&lt;br /&gt;We have seen that we can open and work with external data sources like &lt;b&gt;dBase Tables, Excel databases&lt;/b&gt; and &lt;b&gt;AS400(iSeries) Tables&lt;/b&gt; directly without linking them permanently with MS-Access and familiarized these procedures through the following Articles:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/07/opening-external-data-sources.shtml"&gt;Opening External Data Sources&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/07/opening-dbase-files-directly.shtml"&gt;Opening dBase Files Directly&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Display Excel Value Directly on Form&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/08/opening-excel-database-directly.shtml"&gt;Opening Excel Database Directly&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/08/database-connection-string-properties.shtml"&gt;Database Connection String Properties&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/08/ms-access-live-data-in-excel.shtml"&gt;Access Live Data in Excel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/08/access-live-data-in-excel-2.shtml"&gt;Access Live Data in Excel-2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/source-connect-str-property-and-odbc.shtml"&gt;Source ConnectStr Property and ODBC&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;But, all of them fall into only one category, data files.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To answer the above query we will create a Form with a &lt;b&gt;Datasheet Sub-Form&lt;/b&gt; and with few simple controls to take a listing of a particular category of Files of your choice (&lt;b&gt;Text Files, Word Files, Excel Files or All Files&lt;/b&gt;) from a Folder (including sub-folders, if needed) and display them in a list.  If you would like to open and work with them in their parent Applications, you are welcome to do so by clicking and opening it in their parent Application. An Image of a sample run is given below:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/fileslist01-771654.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 319px; height: 320px;" src="http://msaccesstips.com/uploaded_images/fileslist01-771649.jpg" border="0" alt="Image of External Files List " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All you have to do is to type the File Path like &lt;font class="colrgreen"&gt;C:\Documents and Settings\UserName\My Documents\*.xls&lt;/font&gt; into a Text Box and click a &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt; and there it is; all excel files from the selected folder is presented on the &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Form&lt;/a&gt; as &lt;b&gt;Hyperlinks&lt;/b&gt; on the Datasheet.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I know you are not impressed, because you could memorize and keep entering the above Path or some other Path without difficulty.  Then what about other numerous locations and sub-folders on several Disk Drives? Opening Windows Explorer is out of the question; to find the location and enter it into the Text Box &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Control&lt;/a&gt; manually.  Well, if there is no other way then that also can be done.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;No, you will click on the &lt;b&gt;Path Lookup&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; to invoke something like the Common Dialog Control and browse to the location of the files you are interested in, select one of them and Click the &lt;b&gt;OK&lt;/b&gt; Button. The Files&amp;apos; location address with the File you have selected will be placed in the Text Control. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;That saves a lot of trouble in finding the location of the files. It takes only few clicks of the mouse and we are doing it plenty of times a day.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You may bring in the selected file into the list in &lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Datasheet View&lt;/a&gt; by clicking the &lt;b&gt;Get Files&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Button&lt;/a&gt; or modify the file name part with Wild Card characters (like &lt;b&gt;*.xls, or Acc*.jpg&lt;/b&gt;) to bring in a group of files into the list.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Form has a simple design as you can see from the image given above.  Following are the main elements of the design.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;A Table: &lt;b&gt;DirectoryList&lt;/b&gt; with a single Field &lt;b&gt;FileLinks&lt;/b&gt; with data type &lt;b&gt;Hyperlink&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;A Datasheet &lt;a href="http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml"&gt;Form&lt;/a&gt; created on the above Table with the name &lt;b&gt;FilesListing_Sub&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The Main &lt;a href="http://www.msaccesstips.com/2008/01/progress-bar-on-form.shtml"&gt;Form&lt;/a&gt; &lt;b&gt;FilesListing&lt;/b&gt; with the Datasheet Form inserted as Sub-Form that occupies the major part of the design. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;A Command Button (Name: &lt;b&gt;cmdPathLookup&lt;/b&gt;) with the Caption &lt;b&gt;Path Lookup&lt;/b&gt; runs the Sub-Routine and works like Common Dialog Control to browse and select a file from required location and insert the Path Name in the Text Box below. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;A Text Box with the name &lt;b&gt;PathName&lt;/b&gt; to hold the location address (or &lt;b&gt;Path Name&lt;/b&gt; of the Files) and to modify as per your requirement before you Click the &lt;b&gt;Get Files&lt;/b&gt; Command Button. If you know the Path Name correctly then you may type it in the Text Box directly, whichever is easier to you. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;The Command Button with the name &lt;b&gt;cmdGo&lt;/b&gt; and with the Caption &lt;b&gt;Get Files&lt;/b&gt;, when clicked brings in all the files matching the Path Name specified and displays them in the Data Sheet View above. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;A Combo-Box with the name &lt;b&gt;cboYN&lt;/b&gt; with &lt;b&gt;Yes, No&lt;/b&gt; Values. If you set the value to &lt;b&gt;Yes&lt;/b&gt; before clicking the &lt;b&gt;Get Files&lt;/b&gt; Command Button; all files from the Sub-Folders of the selected folder, if any, also included in the output. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;The Command Button with the name &lt;b&gt;cmdClose&lt;/b&gt; and with the Caption &lt;b&gt;Close&lt;/b&gt; when clicked closes the &lt;b&gt;FilesListing&lt;/b&gt; Main Form. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet(&lt;b&gt;View&lt;/b&gt;- -&gt;&lt;b&gt;Properties&lt;/b&gt;) of the Main Form &lt;b&gt;FilesListing&lt;/b&gt; and change the Property Values as given below to modify its behavior when opened:&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Caption = External Files List&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Default View = Single Form&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Edits = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Deletions = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Additions = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Scroll Bars = Neither&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Record Selectors = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Navigation Buttons = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Dividing Lines = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Auto Re-Size = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Auto Center = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Pop up = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Modal = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Border Style = Dialog&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Control Box = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Min Max Buttons = None&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Close Button = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Design Changes = Design View Only&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;The image of the Main Form in design view is given below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/fileslist02-710731.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 300px;" src="http://msaccesstips.com/uploaded_images/fileslist02-710722.jpg" border="0" alt="External Files List Control Design View" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The heading Labels &lt;b&gt;External Files List&lt;/b&gt; is created with the &lt;b&gt;3D Text&lt;/b&gt; Creation Program and modified to look like the above design.  You can download this &lt;b&gt;3D Text Creation Wizard&lt;/b&gt; from any of the following links:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Create 3D Headings on Forms&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2006/09/border2d-heading-text.shtml"&gt;Border 2D Heading Text&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2006/09/border3d-heading.shtml"&gt;Border 3D Heading&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2006/09/shadow3d-heading-style.shtml"&gt;Shadow 3D Heading Style.&lt;/a&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The Files&amp;#39; List is created as &lt;b&gt;Hyperlinks&lt;/b&gt; in the target table: &lt;b&gt;DirectoryList&lt;/b&gt;, every time, replacing the existing list of files, and appears in Datasheet View.  You may click on the &lt;b&gt;HyperLink&lt;/b&gt; to open that file in its parent Application to work with it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can delete unwanted files from the list.  Select a record by clicking on the left border of the list and press &lt;b&gt;Delete&lt;/b&gt; Key or press &lt;b&gt;Ctrl+-&lt;/b&gt; (press and hold &lt;b&gt;Ctrl&lt;/b&gt; Key and press &lt;b&gt;-&lt;/b&gt; Key).  You cannot add a record manually or edit a record on the Datasheet (you may do so directly on the Table, if you like to mess around with it) so that the &lt;b&gt;HyperLink&lt;/b&gt; Value &lt;b&gt;Segments&lt;/b&gt; are not altered.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you would like to know more about the &lt;b&gt;Hyperlink&lt;/b&gt; value &lt;b&gt;Segments&lt;/b&gt; (four of them) and what they do; go to the link &lt;a href="http://www.msaccesstips.com/2007/05/open-forms-with-hyperlinks-in-listbox.shtml"&gt;Open Forms with Hyperlinks in ListBox&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You may download the sample database from the bottom of this Post and try it out before you design one of your own to understand it better.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can easily implement this in your various Projects by simply importing the Forms and the Table into them.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It is Access2000 Version file and Access97 users cannot use it.  But, you can design the above Forms and Controls with their &lt;b&gt;specific names&lt;/b&gt; as explained above by following &lt;b&gt;Step-1 to 9&lt;/b&gt;.&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;The Sub-Routines and Function which runs behind the Main Form &lt;b&gt;FilesListing&lt;/b&gt; is given below.  You may create the above design with the correct names explained under &lt;b&gt;Steps-1 to 9&lt;/b&gt;, copy and paste the complete Code in the Main Form &lt;b&gt;Class Module&lt;/b&gt; and save the Form.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Option Compare Database&lt;br /&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Private Sub cmdClose_Click()&lt;br /&gt;DoCmd.Close acForm, Me.Name&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdGo_Click()&lt;br /&gt;Dim strtxt As String&lt;br /&gt;On Error GoTo cmdGo_Click_Err&lt;br /&gt;strtxt = Nz(Me![PathName], &amp;quot;&amp;quot;)&lt;br /&gt;New_Search strtxt, Me!cboYN&lt;br /&gt;Me.FilesListing_sub.Form.Requery&lt;br /&gt;&lt;br /&gt;cmdGo_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdGo_Click_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;cmdGo_Click&amp;quot;&lt;br /&gt;Resume cmdGo_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdPathLookup_Click()&lt;br /&gt;'=============================================&lt;br /&gt;'Source Code : Northwind.mdb sample database&lt;br /&gt;'=============================================&lt;br /&gt;    ' Displays the Office File Open dialog to choose a file name&lt;br /&gt;    ' If the user selects a file&lt;br /&gt;    ' display it in the Pathname control.&lt;br /&gt;    Dim result As Integer&lt;br /&gt;    On Error GoTo cmdPathLookup_Click_Err&lt;br /&gt;    With Application.FileDialog(msoFileDialogFilePicker)&lt;br /&gt;        .Title = &amp;quot;Select a File from Target Folder&amp;quot;&lt;br /&gt;        .Filters.Add &amp;quot;All Files&amp;quot;, "*.*"&lt;br /&gt;        .FilterIndex = 1&lt;br /&gt;        .AllowMultiSelect = False&lt;br /&gt;        .InitialFileName = CurrentProject.path&lt;br /&gt;        result = .Show&lt;br /&gt;        If (result &amp;lt;&amp;gt; 0) Then&lt;br /&gt;            Me!PathName = Trim(.SelectedItems.Item(1))&lt;br /&gt;        End If&lt;br /&gt;    End With&lt;br /&gt;    &lt;br /&gt;cmdPathLookup_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdPathLookup_Click_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;cmdPathLookup_Click&amp;quot;&lt;br /&gt;Resume cmdPathLookup_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;Me!PathName = CurrentProject.path &amp;amp; &amp;quot;\*.*&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Function New_Search(ByVal strFilePathName As String, boolsubfolders As Boolean)&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;'Author : a.p.r. pillai&lt;br /&gt;'Date   : Feb. 2009&lt;br /&gt;'URL    : www.msaccesstips.com&lt;br /&gt;'All Rights Reserved by www.msaccesstips.com&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;Dim i, strFolder As String, strFiles As String, locn As Long&lt;br /&gt;Dim db As Database, rst As Recordset, xtn As Integer&lt;br /&gt;&lt;br /&gt;'On Error GoTo New_Search_Err&lt;br /&gt;&lt;br /&gt;If Len(Trim(strFilePathName)) = 0 Then&lt;br /&gt;   MsgBox &amp;quot;File Path Name required.&amp;quot;&lt;br /&gt;   Exit Function&lt;br /&gt;End If&lt;br /&gt;xtn = InStr(1, strFilePathName, &amp;quot;.&amp;quot;)&lt;br /&gt;locn = InStrRev(strFilePathName, &amp;quot;\&amp;quot;)&lt;br /&gt;&lt;br /&gt;If xtn &amp;gt; 0 And locn &amp;gt; 0 Then&lt;br /&gt;   strFiles = Trim(Mid(strFilePathName, locn + 1))&lt;br /&gt;   strFolder = Trim(Left(strFilePathName, locn - 1))&lt;br /&gt;ElseIf xtn &amp;gt; 0 And locn = 0 Then&lt;br /&gt;   strFiles = Trim(strFilePathName)&lt;br /&gt;   If Len(Left(strFiles, xtn - 1)) = 0 Then&lt;br /&gt;      MsgBox &amp;quot;Invalid File specification.&amp;quot;&lt;br /&gt;      Exit Function&lt;br /&gt;   End If&lt;br /&gt;   strFolder = CurrentProject.path &amp;amp; &amp;quot;\*.*&amp;quot;&lt;br /&gt;ElseIf xtn = 0 And locn &amp;gt; 0 Then&lt;br /&gt;   strFiles = &amp;quot;*.*&amp;quot;&lt;br /&gt;   strFolder = Trim(strFilePathName)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;With Application.FileSearch&lt;br /&gt;'the .NewSearch resets earlier search property values to defaults&lt;br /&gt;    .NewSearch&lt;br /&gt;    .LookIn = strFolder&lt;br /&gt;    .SearchSubFolders = boolsubfolders&lt;br /&gt;    .fileName = strFiles&lt;br /&gt;If .Execute() &amp;gt; 0 Then&lt;br /&gt;    i = .FoundFiles.Count&lt;br /&gt;    MsgBox &amp;quot;File found = &amp;quot; &amp;amp; .FoundFiles.Count&lt;br /&gt;    DoCmd.SetWarnings False&lt;br /&gt;    DoCmd.RunSQL &amp;quot;DELETE DirectoryList.* FROM DirectoryList;&amp;quot;&lt;br /&gt;    DoCmd.SetWarnings True&lt;br /&gt;    Set db = CurrentDb&lt;br /&gt;    Set rst = db.OpenRecordset(&amp;quot;DirectoryList&amp;quot;, dbOpenDynaset)&lt;br /&gt;    For i = 1 To .FoundFiles.Count&lt;br /&gt;        rst.AddNew&lt;br /&gt;        strFiles = Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), &amp;quot;\&amp;quot;) + 1)&lt;br /&gt;        strFiles = strFiles &amp;amp; &amp;quot;#&amp;quot; &amp;amp; .FoundFiles(i) &amp;amp; &amp;quot;##Click&amp;quot;&lt;br /&gt;        rst![FileLinks] = strFiles&lt;br /&gt;        rst.Update&lt;br /&gt;    Next&lt;br /&gt;Else&lt;br /&gt;    MsgBox &amp;quot;No matching File Names found!&amp;quot;&lt;br /&gt;End If&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;New_Search_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;New_Search_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;New_Search&amp;quot;&lt;br /&gt;Resume New_Search_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If there is any difficulty in running the &lt;b&gt;On Click Event Procedure&lt;/b&gt; of the &lt;b&gt;Path Lookup&lt;/b&gt; Command Button then replace that with the &lt;b&gt;File Browser&lt;/b&gt; method explained in the Article: &lt;a href="http://www.msaccesstips.com/2006/10/file-browser-in-msaccess.shtml"&gt;File Browser in MS-Access&lt;/a&gt; (Common Dialog Control).&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/downloads/2009/02/DirListing2K.zip"&gt;&lt;img src="http://www.msaccesstips.com/images/zip.gif" border="0"&gt;&lt;font size="3" color="Blue"&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/font&gt; - File: &lt;font size="3" color="green"&gt;&lt;b&gt;DirListing2K.zip&lt;/b&gt;&lt;/font&gt; (Size:36.6K)&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml&amp;title=External+Files+List+in+HyperLinks"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Event Trapping &amp; Summary on Datasheet&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Sum() Min() Max() ParamArray&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Box and Label Inner Margins&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Multiple Parameters for Query&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/form-menu-bars-and-toolbars.shtml"&gt;Form Menu Bars and Toolbars&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5796149844214073284?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cN0CDuvdOlc:1PZ5QbijpN4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cN0CDuvdOlc:1PZ5QbijpN4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cN0CDuvdOlc:1PZ5QbijpN4:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=cN0CDuvdOlc:1PZ5QbijpN4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=cN0CDuvdOlc:1PZ5QbijpN4:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/cN0CDuvdOlc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/cN0CDuvdOlc/external-files-list-in-hyperlinks.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/02/external-files-list-in-hyperlinks.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5626839515299817375</guid><pubDate>Fri, 30 Jan 2009 11:52:00 +0000</pubDate><atom:updated>2009-01-31T08:06:08.133+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess controls</category><title>Combo-Box Column Values</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yy_uxeN5Eb4OwO5Z3YwPNUpmrZw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yy_uxeN5Eb4OwO5Z3YwPNUpmrZw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yy_uxeN5Eb4OwO5Z3YwPNUpmrZw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yy_uxeN5Eb4OwO5Z3YwPNUpmrZw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Command Buttons are the most commonly used control on a &lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Form&lt;/a&gt;. We have seen them in action in different ways and with different designs. Those who have not come across those Articles before then links to them are given below; you may take a look at them.&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt; &lt;a href="http://www.msaccesstips.com/2006/09/command-button-animation.shtml"&gt;  Command Button Animation&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt; &lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt; Command Button Animation-2&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Double-Action Command Button&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt; &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Colorful Command Buttons&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt; &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Transparent Command Button&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Next in line is the most preferred and familiar control on Forms; the &lt;b&gt;Combo-Box&lt;/b&gt; Control. This can be created not only on &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Forms&lt;/a&gt; but also on &lt;b&gt;Tables&lt;/b&gt; as well. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you would like to see few examples for the usage of Combo-Boxes in Tables then you have them on your PC itself.  Open &lt;b&gt;Northwind.mdb&lt;/b&gt; sample database from &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb&lt;/font&gt; (MS-Office2003 pathname) and open &lt;b&gt;Employees&lt;/b&gt; Table or &lt;b&gt;Orders&lt;/b&gt; Table or &lt;b&gt;Order Details&lt;/b&gt; Table in Design View and look at the &lt;b&gt;Fields&lt;/b&gt; and &lt;b&gt;Properties&lt;/b&gt; given under each Table listed below:&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Employees&lt;/b&gt; Table&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Field: &lt;font class="colrgreen"&gt;TitleofCourtesy&lt;/font&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt;: Select the &lt;font class="colrgreen"&gt;Lookup&lt;/font&gt; Tab from the &lt;b&gt;Field Properties&lt;/b&gt; below. Inspect the &lt;b&gt;Row Source Type&lt;/b&gt; and &lt;b&gt;Row Source&lt;/b&gt; Property Values.  Check the other related &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; settings as well.&lt;/br&gt;&lt;br /&gt;  &lt;br /&gt;The &lt;b&gt;Row Source&lt;/b&gt; Property Values are keyed-in as Constants separated by semi-colons after setting the &lt;b&gt;Row Source Type&lt;/b&gt; value as &lt;b&gt;Value List&lt;/b&gt;. This is a single column list.&lt;br&gt;&lt;br /&gt; &lt;br /&gt;To enter values for a two column list the &lt;b&gt;Column Count&lt;/b&gt; Property value must be &lt;b&gt;2&lt;/b&gt; and based on that the values entered into the &lt;b&gt;Row Source&lt;/b&gt; property will be read in pairs to display.&lt;br&gt;&lt;br /&gt; &lt;br /&gt;While using the constant values (&lt;font class="colrgreen"&gt; Dr.;Mr.;Miss;Mrs.;Ms.&lt;/font&gt;) as Source items for the Combo-Box it is assumed that values other than these are not likely to enter into this field, but if necessary you may enter them manually into the target field. The &lt;b&gt;Limit To List&lt;/b&gt; Property Value setting to &lt;b&gt;No&lt;/b&gt; suggests this.&lt;br&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Field: &lt;font class="colrgreen"&gt;ReportsTo&lt;/font&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt;  The &lt;b&gt;Row Source&lt;/b&gt; Property value &lt;b&gt;EmployeelD&lt;/b&gt; is taken for the &lt;b&gt;ReportsTo&lt;/b&gt; Field from the same &lt;b&gt;Employees&lt;/b&gt; Table.&lt;br&gt;&lt;br /&gt;   &lt;br /&gt;The &lt;b&gt;Row Source Type&lt;/b&gt; Value is &lt;b&gt;Table/Query&lt;/b&gt; and the &lt;b&gt;Row Source&lt;/b&gt; Value is an SQL statement, which pulls data from selected fields from the Employees table itself.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here, the &lt;b&gt;Limit To List&lt;/b&gt; Property value is set to &lt;b&gt;Yes&lt;/b&gt; indicating that values other than what is appearing in the &lt;b&gt;Combo-Box&lt;/b&gt; (or in &lt;b&gt;EmployeelD&lt;/b&gt; field) will not be accepted in this field. In other words you cannot enter a value manually into this field, other than what is appearing in the Combo-Box.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;With this setting an automatic validation check is performed by the &lt;a href="http://www.msaccesstips.com/2008/03/refresh-dependant-combo-box-contents.shtml"&gt;Combo-Box&lt;/a&gt; to prevent invalid values creeping into the target data field.  If new value is required, then that must be entered into the source Table/Field of the Combo-box first before that can be inserted into the target field.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The Combo-Boxes created in the Table Structure have more control over the data going into the target field than an external Combo-Box created on a &lt;a href="http://www.msaccesstips.com/2008/01/progress-bar-on-form.shtml"&gt;Form&lt;/a&gt;.  A Form or &lt;a href="http://www.msaccesstips.com/2008/02/union-query.shtml"&gt;Query&lt;/a&gt; designed with this Table Column will have the Combo-Box attached to it when the Field is dragged from the Field-List to the Form or Query, or when you create a Form or &lt;a href="http://www.msaccesstips.com/2007/10/dynamic-report.shtml"&gt;Report&lt;/a&gt; with the built-in &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Wizards&lt;/a&gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Orders&lt;/b&gt; Table&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;font class="colrgreen"&gt;CustornerlD&lt;/li&gt;&lt;br /&gt;&lt;li&gt;EmployeelD&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Shipvia&lt;/li&gt;&lt;/font&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Open the &lt;b&gt;Orders Qry&lt;/b&gt; in normal view and click on one of the rows of &lt;b&gt;Customer&lt;/b&gt; Column to see the Combo-Box in action on Query.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Order Details&lt;/b&gt; Table&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;ProductID&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Normally, Combo-Box will have one or more columns of information like &lt;b&gt;EmployeelD&lt;/b&gt; and &lt;b&gt;Employee Name&lt;/b&gt;.  When clicked the first column value is inserted (this depends on the &lt;b&gt;Bound Column&lt;/b&gt; Property Value setting) into the target field and the description appearing in the second Column is shown for information purpose only. &lt;br&gt;&lt;br /&gt;&lt;br /&gt; The &lt;b&gt;Column Width&lt;/b&gt; Property must be set with Values like &lt;font class="colrgreen"&gt;0.5&amp;quot;; 1.5&amp;quot;&lt;/font&gt; for each column and the &lt;b&gt;List Width&lt;/b&gt; Property Value is equal to the value of all Column Widths added together.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In our above example the &lt;b&gt;EmployeelD&lt;/b&gt; is the value inserted into the &lt;b&gt;ReportsTo&lt;/b&gt; field when clicked.  The EmployeelD is a number but the descriptive name is important to the User because it is more meaningful and easy to remember. So in the Combo-Box the EmployeelD number is kept hidden by setting the first Column Width Value as &lt;b&gt;0&amp;quot;&lt;/b&gt;, thereby showing only the name of the Employee in the Combo-Box.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We will go back to the first sentence of the above Paragraph and proceed further on that point.  There are times that we need information from other Columns also to insert into other target fields with one click.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Assume that our Employee Combo-Box have one more column for &lt;b&gt;Designation&lt;/b&gt; (besides EmployeelD and Name) and when clicked this information also must be inserted into another control on the Form. You can do this with a one-line VBA Code in the &lt;b&gt;On Click Event Procedure&lt;/b&gt; in the Form Module like:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;Private Sub EmployeeCombo_Click()&lt;br /&gt;     Me![Designation] = Me!EmployeeCombo.Column(2) &lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The column index numbers of &lt;b&gt;Combo-Boxes&lt;/b&gt; are &lt;b&gt;0&lt;/b&gt; based and the third column has an index value of &lt;b&gt;2&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml&amp;title=Combo-Box+Column+Values"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Sum() Min() Max() ParamArray&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Box and Label Inner Margins&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Multiple Parameters for Query&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/form-menu-bars-and-toolbars.shtml"&gt;Form Menu Bars and Toolbars&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/seriality-control-finding-missing.shtml"&gt;Seriality Control - Missing Numbers&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5626839515299817375?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1EYfJ2sh5Xc:hq2Y9AIZlKI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1EYfJ2sh5Xc:hq2Y9AIZlKI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1EYfJ2sh5Xc:hq2Y9AIZlKI:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=1EYfJ2sh5Xc:hq2Y9AIZlKI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=1EYfJ2sh5Xc:hq2Y9AIZlKI:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/1EYfJ2sh5Xc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/1EYfJ2sh5Xc/combo-box-column-values.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/01/combo-box-column-values.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-4162637087018174027</guid><pubDate>Fri, 23 Jan 2009 17:18:00 +0000</pubDate><atom:updated>2009-01-24T12:01:28.591+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess forms</category><title>Drill-Down Inquiry Screen-2</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/7qo4iEVKUiBqBqixPotb4MnwfLI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7qo4iEVKUiBqBqixPotb4MnwfLI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/7qo4iEVKUiBqBqixPotb4MnwfLI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7qo4iEVKUiBqBqixPotb4MnwfLI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;This is the continuation of earlier Article: Drill-Down Inquiry Screen.  If you have landed on this Page please read the first part of this Article by following this Link: &lt;a href="http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml"&gt;Drill-Down Inquiry Screen&lt;/a&gt; and continue...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I hope you have downloaded the sample database from the bottom of the first part of this Article and tried it out.  Then you have a general idea of the shape of things to come.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here, we will design three small &lt;a href="http://www.msaccesstips.com/2007/08/edit-data-in-zoom-in-control.shtml"&gt;Forms&lt;/a&gt;, assemble them on the Main Form on a &lt;b&gt;Tab Control&lt;/b&gt; and use few lines of Code to refresh the Main Form to update the contents of the &lt;b&gt;Sub-forms&lt;/b&gt; before bringing them into view.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;First, we will design the top layer of the Form for the Employee-wise Order Summary Information.&lt;br&gt; &lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;03_Employee_Summary&lt;/font&gt; &lt;b&gt;Form&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;a href="http://www.msaccesstips.com/2008/02/crosstab-union-queries-for-charts.shtml"&gt;Query&lt;/a&gt; &lt;b&gt;03_Employee_Summary&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Design a Tabular Form (continuous form) like the sample given below.  You may use the &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Form Wizard&lt;/a&gt;&lt;/b&gt; from &lt;b&gt;Insert&lt;/b&gt; Menu to create the Form quickly but it may insert background images and the controls may be created with shadows etc.  In that case you have to modify the design to look like the sample given below.&lt;/li&gt;&lt;br /&gt;&lt;br&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/employeesum-702381.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 146px;" src="http://msaccesstips.com/uploaded_images/employeesum-702373.jpg" border="0" alt="Employee Order Summary Form Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Select all the Data Fields together by clicking on the left side border of &lt;b&gt;Detail Section&lt;/b&gt; or click in Detail Section somewhere and drag the mouse over all the controls to select them together.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Enabled = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Locked = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Tab Stop = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Back Color = 12632256&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Special Effect = Raised&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;Expand the &lt;b&gt;Detail Section&lt;/b&gt; of the Form down to get enough room to draw a lengthy &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml"&gt;Command Button&lt;/a&gt;&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Draw a &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; as wide as the full length of all the Fields above, so that we can cover the fields by placing it over them.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; Sheet of the &lt;a href="http://www.msaccesstips.com/2006/09/command-button-animation.shtml"&gt;Command Button&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = cmd1&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Transparent = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Hyperlink SubAddress = #&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;We must make the Command Button&amp;#39;s height same as of the Fields above.  Click on the Command Button to select it, hold the &lt;b&gt;Shift Key&lt;/b&gt; and click on any one of the Fields above to select it along with the Command Button. Alternatively you can click and drag over the Command Button and any one of the fields above.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;Format&lt;/b&gt; - -&gt; &lt;b&gt;Size&lt;/b&gt; and select &lt;b&gt;Shortest&lt;/b&gt;, if Command Button&amp;#39;s height is more than the field, or select &lt;b&gt;Tallest&lt;/b&gt; to make the Command Button as tall as the fields above.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Drag the &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Transparent Command Button&lt;/a&gt; and place it over the Fields above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;To make sure that the &lt;b&gt;Transparent Command Button&lt;/b&gt; stays above all the data fields, select  &lt;b&gt;Format&lt;/b&gt; - - &gt; &lt;b&gt;Bring to Front&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Now, reduce the &lt;b&gt;Detail Section&lt;/b&gt; height, but there must be little gap above and below the Data Fields.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Draw a &lt;b&gt;Text Box&lt;/b&gt; in the Form &lt;b&gt;Footer Section&lt;/b&gt; below in the same position of &lt;b&gt;TORDERS&lt;/b&gt; field in the &lt;b&gt;Detail Section&lt;/b&gt; and write the following expression in the &lt;b&gt;Control Source&lt;/b&gt; Property:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;=Sum([TORDERS])&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Caption&lt;/b&gt; of the child label to &lt;b&gt;Total Orders&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Label at the Header of the Form and change the &lt;b&gt;Caption&lt;/b&gt; value to &lt;b&gt;EMPLOYEE-WISE ORDERS SUMMARY&lt;/b&gt;. Change the &lt;b&gt;font size&lt;/b&gt; to &lt;b&gt;12&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;b&gt;Code Module&lt;/b&gt; of the Form ( &lt;b&gt;View&lt;/b&gt; - -&gt; &lt;b&gt;Code&lt;/b&gt;), Copy and paste the following &lt;a href="http://www.msaccesstips.com/2008/06/working-with-chart-object-in-vba.shtml"&gt;VBA&lt;/a&gt; lines into the Module:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt; &lt;br /&gt;Private Sub cmd1_Click()&lt;br /&gt;     Me.Parent.Refresh&lt;br /&gt;      Me.Parent.Tabctl0.Pages(1).SetFocus&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Save&lt;/b&gt; the Form with the Name: &lt;b&gt;03_Employee_Summary&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;font class="colrgreen"&gt;04_Order_ListQ&lt;/font&gt; Form&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;a href="http://www.msaccesstips.com/2008/02/union-query.shtml"&gt;Query&lt;/a&gt; &lt;b&gt;04_Order_ListQ&lt;/b&gt; and create a Tabular Form (continuous Form) as we did at the top.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the design to look like the sample Image given below:&lt;/li&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/orderlist-729788.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 150px;" src="http://msaccesstips.com/uploaded_images/orderlist-729785.jpg" border="0" alt="Order List Form Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;li&gt;Select all the fields as we did earlier and change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Enabled = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Locked = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Tab Stop = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Back Color = 16777215&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Special Effect = Flat&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Follow &lt;b&gt;Step-6&lt;/b&gt; to &lt;b&gt;8&lt;/b&gt; given above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Properties of the Command Button:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = cmdOrder&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Transparent = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Hyperlink SubAddress = #&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Follow &lt;b&gt;Step-10&lt;/b&gt; to &lt;b&gt;13&lt;/b&gt; explained above.  Reduce the height of the &lt;b&gt;Detail Section&lt;/b&gt; without leaving gap above and below the fields.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Command Button at the Footer Section of the Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the Command Button and change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = cmdMain&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Caption = Goto Main&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;Expand the &lt;b&gt;Header Section&lt;/b&gt; of the Form and drag the Field Headings down to get enough room to create a &lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Heading&lt;/a&gt; to the Form.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Add a &lt;b&gt;Text Box&lt;/b&gt; above the Field Headings and write the following expression in the &lt;b&gt;Control Source&lt;/b&gt; Property of the Text Box:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt; = &amp;quot;Order List of &amp;quot; &amp;amp; [EmpName]&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;b&gt;Code Module&lt;/b&gt; of the Form (&lt;b&gt;View&lt;/b&gt; - - &gt;&lt;b&gt;Code&lt;/b&gt;), Copy and paste the VBA Code given below into the Module and save the Form with the name &lt;font class="colrgreen"&gt;&lt;b&gt;04_Order_ListQ&lt;/b&gt;.&lt;/font&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub cmdMain_Click()&lt;br /&gt;Me.Parent.Tabctl0.Pages(0).SetFocus&lt;br /&gt;End Sub&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Private Sub cmdOrder_Click()&lt;br /&gt;Me.Parent.Refresh&lt;br /&gt;Me.Parent.Tabctl0.Pages(2).SetFocus&lt;br /&gt;End Sub&lt;br /&gt; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;font class="colrgreen"&gt;05_Order_DetailQ&lt;/font&gt;  Form&lt;/b&gt;.&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;a href="http://www.msaccesstips.com/2008/02/percentage-on-total-query.shtml"&gt;Query&lt;/a&gt; &lt;font class="colrgreen"&gt;05_Order_DetailQ&lt;/font&gt; and Create a Tabular Form.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Here, we don&amp;#39;t need the Transparent Command Button. Change the design of the form to make it like the sample image given below.&lt;br&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/orderdetail-765175.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 138px;" src="http://msaccesstips.com/uploaded_images/orderdetail-764781.jpg" border="0" alt="Order Detail Screen Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;Text Box&lt;/b&gt; in the &lt;b&gt;Form Footer&lt;/b&gt; below the &lt;b&gt;Quantity&lt;/b&gt; field and write the following expression in the &lt;b&gt;Control Source&lt;/b&gt; Property:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;=Sum( [Quantity]) &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create another &lt;b&gt;Text Box&lt;/b&gt; in the &lt;b&gt;Form Footer&lt;/b&gt; below the &lt;b&gt;ExtendedPrice&lt;/b&gt; Column and write the following expression in the &lt;b&gt;Control Source&lt;/b&gt; Property:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;=Sum([ExtendedPrice])&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a Command Button in the Form Footer below the Text Boxes.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values of the Command Button.&lt;/li&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = cmdBack&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Caption = &lt;&lt; Back&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;b&gt;Code Module&lt;/b&gt; of the Form (&lt;b&gt;View&lt;/b&gt; - -&gt; &lt;b&gt;Code&lt;/b&gt;), copy and paste the following lines into the Module:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;Private Sub cmdBack_Click()&lt;br /&gt;Me.Parent.TabCtl0.Pages(1).SetFocus&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Save the Form with the Name &lt;font class="colrgreen"&gt;05_Order_DetailsQ&lt;/font&gt;.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Now, we are ready for the &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Main Form&lt;/a&gt; &lt;font class="colrgreen"&gt;Inquiry_Main&lt;/font&gt; to assemble all the three &lt;b&gt;Sub-Forms&lt;/b&gt; on a &lt;b&gt;Table Control&lt;/b&gt; and make the &lt;b&gt;Tab Control&lt;/b&gt; invisible.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;font class="colrgreen"&gt;Inquiry_Main&lt;/font&gt; Form&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Select the Parameter Table &lt;b&gt;Date_Param&lt;/b&gt;, select &lt;b&gt;Form&lt;/b&gt; from &lt;b&gt;Insert&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml"&gt;Menu&lt;/a&gt; and select &lt;b&gt;Design View&lt;/b&gt; from the displayed List.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;b&gt;Tab Control&lt;/b&gt; Tool from the &lt;b&gt;Toolbox&lt;/b&gt; and draw a Tab Control on the &lt;b&gt;Detail Section&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2007/05/opening-access-forms.shtml"&gt;Form&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check the sample image given below.  The Tab Control will have only two pages when created but we need one more page.&lt;/li&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/inquirymain-760621.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 283px;" src="http://msaccesstips.com/uploaded_images/inquirymain-760586.jpg" border="0" alt="Inquiry Main Screen Image" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;li&gt;Click on the Tab Control to select it and select &lt;b&gt;Tab Control Page&lt;/b&gt; from &lt;b&gt;Insert&lt;/b&gt; &lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars2.shtml"&gt;Menu&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;You may select each &lt;b&gt;Page&lt;/b&gt; of the Tab Control, display their Property Sheet and Change the &lt;b&gt;Caption&lt;/b&gt; Property value of &lt;b&gt;Page1, Page2&lt;/b&gt; and &lt;b&gt;Page3&lt;/b&gt; as &lt;b&gt;Summary, Orders&lt;/b&gt; and &lt;b&gt;Order Detail&lt;/b&gt; respectively, if needed.  It is used for reference purposes only and will not use those names anywhere or display them either.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Next step is to drag and drop the &lt;b&gt;Sub-Forms&lt;/b&gt; (&lt;font class="colrgreen"&gt;03_Employees_Summary, 04_Order_ListQ&lt;/font&gt; and &lt;font class="colrgreen"&gt;05_Order_DetailQ&lt;/font&gt;) one by one on the Tab Control Pages.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Position the &lt;b&gt;Database Window&lt;/b&gt; with the &lt;b&gt;Forms Tab&lt;/b&gt; active and the &lt;b&gt;Inquiry_Main&lt;/b&gt; Form with the Tab Control side by side.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Drag and drop the &lt;b&gt;03_Employee_Summary&lt;/b&gt; Form on the Tab Control &lt;b&gt;Page1&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;You may delete the child label attached to the Sub-Form. Re-size the Sub-Form and Tab Control to display the contents properly on the Screen.  You may save the Form with the name &lt;font class="colrgreen"&gt;Inquiry_Main&lt;/font&gt; and open it in &lt;b&gt;Normal View&lt;/b&gt; to check as how the Information is displayed on the Sub-Form.  If necessary increase or decrease the size of the Form and Tab Control.   Leave some gap between the Tab control and the top of the &lt;b&gt;Detail Section&lt;/b&gt; of the &lt;a href="http://www.msaccesstips.com/2007/12/progress-meter.shtml"&gt;Form &lt;/a&gt;to insert few Text Boxes for &lt;b&gt;StartDate&lt;/b&gt; and &lt;b&gt;EndDate&lt;/b&gt; fields and two more Text Boxes for control purposes. We need space for a heading above these controls as well.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;When you are satisfied with the Sub-Form dimension for the design, click on the Sub-Form and display the Property Sheet. Take a piece of paper and note down the following Property Values for resizing and positioning the other two forms we are going to insert into &lt;b&gt;Page2&lt;/b&gt; and &lt;b&gt;Page3&lt;/b&gt; of the Tab Control.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Top&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Left&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Width&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Height&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;Right-click on the Sub-Form and select &lt;b&gt;Copy&lt;/b&gt; from the displayed &lt;a href="http://www.msaccesstips.com/2007/12/keyboard-shortcuts.shtml"&gt;Shortcut&lt;/a&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select Tab Control &lt;b&gt;Page2&lt;/b&gt;, press and hold &lt;b&gt;Shift&lt;/b&gt; Key, right-click on the Tab Control &lt;b&gt;Page2&lt;/b&gt; and select &lt;b&gt;Paste&lt;/b&gt; from the displayed menu.&lt;br /&gt;The pasted control will be an empty form displaying the &lt;b&gt;Source Object Name&lt;/b&gt; of the copied Form with white background.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Property sheet of the Form and change the &lt;b&gt;Source Object&lt;/b&gt; Property value to &lt;font class="colrgreen"&gt;04_Order_ListQ&lt;/font&gt;. After this change the Form will appear on the Tab Control Page2.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Change the dimension property values to the same value you have noted down.  Since, you have copied the Form (no drag and drop from Database Window); you need to change only the &lt;b&gt;Top&lt;/b&gt; and &lt;b&gt;Left&lt;/b&gt; Property Values, &lt;b&gt;Width&lt;/b&gt; and &lt;b&gt;Height&lt;/b&gt; values will be same.  If not then change it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Follow &lt;b&gt;Step-9&lt;/b&gt; to &lt;b&gt;12&lt;/b&gt; above to bring in the &lt;font class="colrgreen"&gt;05_Order_DetailQ&lt;/font&gt; Form into the third Page of the Tab Control.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the &lt;b&gt;Field List&lt;/b&gt; (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Field List&lt;/b&gt;), if it is not visible.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Drag and drop &lt;b&gt;StartDate&lt;/b&gt; and &lt;b&gt;EndDate&lt;/b&gt; field above the Tab Control,  create labels above and left and change their &lt;b&gt;Caption&lt;/b&gt; values as shown on the design above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;Command Button&lt;/b&gt; to the right of &lt;b&gt;EndDate&lt;/b&gt; field and change its property values as given below:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = cmdRefresh&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Caption = &amp;lt;&amp;lt;Refresh Screen&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The Date Fields we have created and another two Text Boxes, which we are going to create, will be referenced in the Queries we have created earlier to filter the data for the Forms to display.  Even though this refresh action is not necessary, as we do that before we display the results, it is an additional feature to refresh the changes manually by the User.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;Text Box&lt;/b&gt; to the right of the Command Button and display its property sheet and change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = EID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Control Source = =[03_Employee_Summary].Form!EmployeeID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Visible = No&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;Create another &lt;b&gt;Text Box&lt;/b&gt; below the earlier one and change the property values as given below.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = OID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Control Source = =[04_Order_ListQ].Form!OrderID&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Visible = No&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;Create a heading on top of the Form with the &lt;b&gt;Caption&lt;/b&gt; Value &lt;b&gt;SALES PERFORMANCE INQUIRY.&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;Command Button&lt;/b&gt; below the Tab Control and change the following property values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name = cmdQuit&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Caption = Quit&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;Now, we are going to make the &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-menu-design.shtml"&gt;Tab Control&lt;/a&gt; disappear, well the Tab Control will not look like a Tab Control after the change, to be exact.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Click on the Tab Control, display the Property sheet and change the following property values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Caution:&lt;/b&gt; Immediately after you change the Property values make a point to click the &lt;b&gt;Save&lt;/b&gt; Toolbar Button or select &lt;b&gt;Save&lt;/b&gt; from &lt;b&gt;File&lt;/b&gt; Menu to save the changes.  There is a tendency to lock-up the Form in Office2000, if you attempt to do anything else.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Back Style = Transparent&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Multirow = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Style = None&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the Form, copy and paste the following few lines of Code into the Module:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;Private Sub cmdQuit_Click()&lt;br /&gt;      DoCmd.Close acForm, Me.Name&lt;br /&gt;End Sub&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Private Sub cmdRefresh_Click()&lt;br /&gt;     Me.Refresh&lt;br /&gt;End Sub&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Private Sub EndDate_LostFocus()&lt;br /&gt;    Me.Refresh&lt;br /&gt;End Sub&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;     Me.TabCtl0.Pages(0).SetFocus&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;We will finish the design by setting the Property Values of the &lt;font class="colrgreen"&gt;Inquiry_Main&lt;/font&gt; Form. Display the Property Sheet of the Form and change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Allow Edits = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Deletiions = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Additions = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Data Entry = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Scroll Bars = Neither&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Record Selectors = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Navigation Buttons = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Dividing Lines = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Auto Re-size = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Auto Center = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Pop up = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Modal = No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Border Style = Dialog&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Control Box = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Min Max Buttons = None&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Close Button = Yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Allow Design Changes = Design View Only&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;li&gt;Save the Form, open it in Normal View and try out your creation.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; If you face any difficulty in running your design normally, use the downloaded database as reference, find the mistake and correct it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml&amp;title=Drill-Down+Inquiry+Screen-2"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/textbox-and-label-inner-margins.shtml"&gt;Text Box and Label Inner Margins&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Multiple Parameters for Query&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/form-menu-bars-and-toolbars.shtml"&gt;Form Menu Bars and Toolbars&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/seriality-control-finding-missing.shtml"&gt;Seriality Control - Missing Numbers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Wave Shaped Reminder Ticker&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-4162637087018174027?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=F3PDG80qnc0:evcQ7yEoBcA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=F3PDG80qnc0:evcQ7yEoBcA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=F3PDG80qnc0:evcQ7yEoBcA:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=F3PDG80qnc0:evcQ7yEoBcA:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=F3PDG80qnc0:evcQ7yEoBcA:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/F3PDG80qnc0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/F3PDG80qnc0/drill-down-inquiry-screen-2.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen-2.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-6535993887459584787</guid><pubDate>Sat, 17 Jan 2009 12:28:00 +0000</pubDate><atom:updated>2009-01-17T17:37:50.566+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess forms</category><title>Drill-Down Inquiry Screen</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CA5LucuBt0I2rrtzuenCfaJeP_Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CA5LucuBt0I2rrtzuenCfaJeP_Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CA5LucuBt0I2rrtzuenCfaJeP_Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CA5LucuBt0I2rrtzuenCfaJeP_Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Following is an image of a three layer Inquiry Screen, designed for the Management, to keep track of &lt;i&gt;Northwind Traders&lt;/i&gt; staff-level Sales Performance:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/011enquiry-701494.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 290px;" src="http://msaccesstips.com/uploaded_images/011enquiry-701487.jpg" border="0" alt="Employee-level Summary" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;The top layer of the &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Form&lt;/a&gt; shows Sales-Person level summary of Orders and the &lt;a href="http://www.msaccesstips.com/2008/02/percentage-on-total-query.shtml"&gt;Percentage on Total&lt;/a&gt; Orders. At the Footer of the &lt;a href="http://www.msaccesstips.com/2007/07/animated-floating-calendar.shtml"&gt;Form&lt;/a&gt; shows the Total of all Orders put together. When clicked on a particular Employee’s record the individual Order-level Summary information will be visible on the main screen overlaying the earlier view. Check the image given below.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/021enquiry-761358.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 290px;" src="http://msaccesstips.com/uploaded_images/021enquiry-761353.jpg" border="0" alt="Order-wise Summary Screen" /&gt;&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Several items can be ordered under a particular Order and details of all items can be displayed by Clicking on one of the Order record. Check the image given below.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/031enquiry-715082.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 290px;" src="http://msaccesstips.com/uploaded_images/031enquiry-715078.jpg" border="0" alt="Order Details Screen" /&gt;&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The above &lt;a href="http://www.msaccesstips.com/2007/05/open-forms-with-hyperlinks-in-listbox.shtml"&gt;Form&lt;/a&gt; shows order-level details and summary information at the Footer of the form with &lt;b&gt;Total Quantity&lt;/b&gt; of all Orders and the &lt;b&gt;Total Net-Value&lt;/b&gt; of all items after discount. The &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Buttons&lt;/a&gt; at the footer of each form is used to switch the view back to the upper layer of the form.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;Date Parameter&lt;/b&gt; values at the top can be changed to display information for a different period.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;First of all, I would like to assure you that there is no complicated VBA Code to drive this design except one or two lines of them here and there to refresh the controls and for switching from one layer of the form to the other.  Other than that the entire Screen works on &lt;a href="http://www.msaccesstips.com/2008/04/finding-consecutive-workdays-with-query.shtml"&gt;Queries&lt;/a&gt; and &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Forms&lt;/a&gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We need few Tables from &lt;b&gt;Northwind.mdb&lt;/b&gt; sample database, to create six simple &lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Queries&lt;/a&gt;, three &lt;b&gt;Sub-Forms&lt;/b&gt; and a &lt;b&gt;Main Form&lt;/b&gt; to organize all of them together to present the information to the User.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you would like to see the &lt;b&gt;Inquiry Screen&lt;/b&gt; in action before you design it, you can download it from the bottom of this post and take a look at it. If you find it difficult to figure it out how it works or how to put all of them together then come back and go through the design task step by step so that you will know how simple or difficult it is and how each element of this trick works together with others.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here, we will see the usage of &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Transparent Command Buttons&lt;/a&gt; again, which we have already seen in an earlier Article with the same Title.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We will have to split this topic into more than one Blog-Post so that we can do the design task with ease. Even though I can show you how to do it in few minutes, explaining that on paper with images and &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Property&lt;/a&gt; settings takes lot more than that.&lt;br&gt;  &lt;br /&gt;&lt;br /&gt;I know, if you download the database and take a look at it first, you will be better prepared to find out more about it and ready to go through the design task with more interest.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So, let us start the first part.&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Download the following Tables from &lt;font class="colrgreen"&gt;C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb&lt;/font&gt; (MSOffice2003 address, you can replace &lt;b&gt;Office&lt;/b&gt; in place of &lt;b&gt;Office11&lt;/b&gt; if your Version of Access is 2000):&lt;/li&gt;&lt;br&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Employees&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Orders&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Order_Details&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Products&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;b&gt;Parameter Table&lt;/b&gt; with the following name and Structure:&lt;/li&gt;&lt;br /&gt;&lt;table width="200" border="1" cellpadding="3" cellspacing="0"&gt;&lt;br /&gt;&lt;tr&gt;&lt;th width="50%"&gt;Field Name&lt;/th&gt;&lt;th width="50%"&gt;Data Type&lt;/th&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td width="50%" align="center"&gt;StartDate&lt;/td&gt;&lt;td width="50%" align="center"&gt;Date&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td width="50%" align="center"&gt;EndDate&lt;/td&gt;&lt;td width="50%" align="center"&gt;Date&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the Table and create a single record with the following &lt;b&gt;StartDate&lt;/b&gt; and &lt;b&gt;EndDate&lt;/b&gt; values and save the record:&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;StartDate = &lt;b&gt;01-01-1996&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;EndDate = &lt;b&gt;31-12-1996&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open new &lt;a href="http://www.msaccesstips.com/2008/02/union-query.shtml"&gt;Queries&lt;/a&gt; and Copy the following &lt;b&gt;SQL&lt;/b&gt; Strings into Query&amp;#39;s &lt;b&gt;SQL Editing&lt;/b&gt; Window and save them with exact Name given for each of them.  Create the Queries in the same order as given here as they have dependencies on Queries created first.&lt;/li&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;00_Orders_MainQ&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;SELECT Orders.*&lt;br /&gt;FROM Orders, Date_Param&lt;br /&gt;WHERE (((Orders.OrderDate) Between [StartDate] And [EndDate]));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;01_OrderCount1&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;SELECT Employees.EmployeeID, &lt;br /&gt;        [FirstName] &amp;amp; &amp;quot; &amp;quot; &amp;amp; [LastName] AS EmpName, &lt;br /&gt;         Count([00_Orders_MainQ].OrderID) AS TORDERS&lt;br /&gt;FROM Employees INNER JOIN 00_Orders_MainQ ON Employees.EmployeeID = [00_Orders_MainQ].EmployeeID&lt;br /&gt;GROUP BY Employees.EmployeeID, [FirstName] &amp;amp; &amp;quot; &amp;quot; &amp;amp; [LastName];&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;02_OrderCount2&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;SELECT Count([00_Orders_MainQ].OrderID) AS TOTALORDERS&lt;br /&gt;FROM 00_Orders_MainQ;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;03_Employee_Summary&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt1"&gt;&lt;br /&gt;SELECT [01_OrderCount1].*,&lt;br /&gt;      [TORDERS]/[TOTALORDERS] AS PCNT&lt;br /&gt;FROM 01_OrderCount1, 02_OrderCount2;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;04_Order_ListQ&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;SELECT [00_Orders_MainQ].OrderID, &lt;br /&gt;       UCase([FirstName] &amp;amp; &amp;quot; &amp;quot; &amp;amp; [Lastname]) AS EmpName,&lt;br /&gt;       [00_Orders_MainQ].OrderDate, &lt;br /&gt;       [00_Orders_MainQ].RequiredDate&lt;br /&gt;FROM Employees INNER JOIN 00_Orders_MainQ ON Employees.EmployeeID = [00_Orders_MainQ].EmployeeID&lt;br /&gt;WHERE ((([00_Orders_MainQ].EmployeeID)=[Forms]![Inquiry_Main]![EID]));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Query Name: &lt;b&gt;05_Order_DetailQ&lt;/b&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;SELECT [FirstName] &amp;amp; &amp;quot; &amp;quot; &amp;amp; [LastName] AS EmpName, &lt;br /&gt;        [Order Details].OrderID,&lt;br /&gt;        [Order Details].ProductID, &lt;br /&gt;        [Order Details].Quantity,&lt;br /&gt;        [Order Details].UnitPrice, &lt;br /&gt;        [Order Details].Discount, &lt;br /&gt;        (1-[Discount])*[UnitPrice]*[Quantity] AS ExtendedPrice&lt;br /&gt;FROM (Employees INNER JOIN 00_Orders_MainQ ON Employees.EmployeeID = [00_Orders_MainQ].EmployeeID) INNER JOIN [Order Details] ON [00_Orders_MainQ].OrderID = [Order Details].OrderID&lt;br /&gt;WHERE ((([Order Details].OrderID)=[Forms]![Inquiry_Main]![OID]));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Contd/-...&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Download Link :&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/downloads/2009/01/inquirydemo00.zip"&gt;&lt;img src="http://www.msaccesstips.com/images/zip.gif" border="0"&gt;&lt;font size="3" color="Blue"&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/font&gt; - File: &lt;font size="3" color="green"&gt;&lt;b&gt;inquirydemo00.zip&lt;/b&gt;&lt;/font&gt; (Size:137K)&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml&amp;title=Drill-Down+Inquiry+Screen"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/multiple-parameters-for-query.shtml"&gt;Multiple Parameters for Query&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/form-menu-bars-and-toolbars.shtml"&gt;Form Menu Bars and Toolbars&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/seriality-control-finding-missing.shtml"&gt;Seriality Control - Missing Numbers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Wave Shaped Reminder Ticker&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;No Data and Report Error&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-6535993887459584787?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=XzhB-vUw5Zc:cqILK7U40ds:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=XzhB-vUw5Zc:cqILK7U40ds:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=XzhB-vUw5Zc:cqILK7U40ds:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=XzhB-vUw5Zc:cqILK7U40ds:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=XzhB-vUw5Zc:cqILK7U40ds:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/XzhB-vUw5Zc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/XzhB-vUw5Zc/drill-down-inquiry-screen.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/01/drill-down-inquiry-screen.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5976876423197650064</guid><pubDate>Sat, 10 Jan 2009 08:58:00 +0000</pubDate><atom:updated>2009-01-10T14:30:58.368+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess animation</category><title>Command Button Animation-2</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/H59o2LDkggvxRBXAX2h9jqtyZ4k/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/H59o2LDkggvxRBXAX2h9jqtyZ4k/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/H59o2LDkggvxRBXAX2h9jqtyZ4k/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/H59o2LDkggvxRBXAX2h9jqtyZ4k/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;A Screen with Animated Text or Controls gives the application a lively look and feel than a rigid screen to the user as well as to the onlooker.  &lt;a href="http://www.msaccesstips.com/2006/09/command-button-animation.shtml"&gt;Command Button Animation&lt;/a&gt; was the first Blog-Post that I have published on this site.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Another Screen design improvement was creating &lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;3D headings on Form&lt;/a&gt; and &lt;a href="http://www.msaccesstips.com/2007/08/highlighting-reports.shtml"&gt;Report&lt;/a&gt; with different Fonts, Sizes and Styles.  Initially, created them manually and this lead to the creation of a &lt;a href="http://www.msaccesstips.com/downloads/2006/09/3DHeadings.zip"&gt;3D-Text Wizard&lt;/a&gt;. You can download this Wizard by following the highlighted link or from &lt;b&gt;Downloads&lt;/b&gt; Menu.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can find the details of 3D Text Styles in the following Posts and download the Wizard from any one of the Posts:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Create 3D Headings on Forms&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/border2d-heading-text.shtml"&gt;Border 2D Heading Text&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/border3d-heading.shtml"&gt;Border 3D Heading&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/shadow3d-heading-style.shtml"&gt;Shadow 3D Heading Style&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;IBM AS400 (iSeries) Screens influenced me to go along designing MS-Access Screens with dark background, data labels with light shades and information in Green text. Even though these are old text based screens better visibility of information is the main attraction of these screens.&lt;br&gt;  &lt;br /&gt;&lt;br /&gt;But, when I started designing them I faced little problem with the Command Button Animation that was in use till that time because it was not designed for dark backgrounds. I had to invent a different animation method around the original command button. It is simple to design besides easy to implement without the use of too complex VBA code.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So, here it is for you and I hope you like it too.  First, we will implement it with a simple and easy to understand method.  After that we will write a common routine that can drive the animation on any form with one or two lines of Code.&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open a new Form or an existing one.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;b&gt;Footer&lt;/b&gt; of the Form. If it is not visible select &lt;b&gt;Form Header/Footer&lt;/b&gt; from &lt;b&gt;View&lt;/b&gt; Menu.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Back Color&lt;/b&gt; Property Value to &lt;b&gt;0&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;b&gt;Command Button&lt;/b&gt; Tool from &lt;b&gt;Toolbox&lt;/b&gt; and draw a Command Button in the &lt;b&gt;Footer Section&lt;/b&gt; of the Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the Command Button.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; property Value to &lt;b&gt;cmdExit&lt;/b&gt; and &lt;b&gt;Caption&lt;/b&gt; property value to &lt;b&gt;Exit&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the &lt;b&gt;Rectangle Tool&lt;/b&gt; from &lt;b&gt;Toolbox&lt;/b&gt; and draw a rectangle around the Command Button as shown in the sample design below:&lt;/li&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/button2_1-792534.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 67px;" src="http://msaccesstips.com/uploaded_images/button2_1-792532.jpg" border="0" alt="Button Animation Style-2" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Give a little more gap, between the button and the rectangle at the bottom and the right side than above and left, giving it a feel that the Command Button is in a raised state.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the Rectangle and display its Property Sheet.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value to &lt;b&gt;ExitBox&lt;/b&gt; and the &lt;b&gt;Visible&lt;/b&gt; Property Value to &lt;b&gt;No&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;Now, it is time to implement the animation trick.  This time, we will not animate the button like we did earlier on the Command Button Animation; instead the Box around it will be made visible or hidden based on the Mouse movement over the Command Button.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We will track the mouse movement in Code.  When the mouse is over the Command Button the rectangle is made visible and when the mouse moves out it is hidden. When this action is repeated it will look like the command button become raised and goes flat again.  It has a better look and feel in dark background rather than remains flat all the time.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We need to place Code at two places to trap the mouse movements, on the &lt;b&gt;On Mouse Move&lt;/b&gt; Event of the Command Button and on the &lt;b&gt;On Mouse Move&lt;/b&gt; Event in the Form Footer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Select the Command Button.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Property Sheet of the Command Button (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &lt;b&gt;[Event Procedure]&lt;/b&gt; in the &lt;b&gt;On Mouse Move&lt;/b&gt; property and click on the build button (&lt;b&gt;…&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the Code given below, between the sub-routine skeleton. You can ignore the first and last lines while copying as these will be present in the Module.&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub cmdExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)&lt;br /&gt;     If Me.ExitBox.Visible = False Then&lt;br /&gt;           Me.ExitBox.Visible = True&lt;br /&gt;     End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Click anywhere within the Form Footer area and display the Property Sheet and repeat &lt;b&gt;Step-14&lt;/b&gt; above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the following Code into the empty skeleton of the sub-routine, as you did above:&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;Private Sub FormFooter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)&lt;br /&gt;   If Me.ExitBox.Visible = True Then&lt;br /&gt;      Me.ExitBox.Visible = False&lt;br /&gt;   End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Actually, the &lt;b&gt;IF…Then&lt;/b&gt; statement is not required in the routine. This is introduced to avoid changing the value repeatedly during mouse movements and to avoid flickering.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Save the Form and open it in Normal view.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Move the Mouse over and out of the Command Button repeatedly which will give the button a sense of going flat and raised state every time.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;When we implement this animation at several places duplicating the above code everywhere is not good programming.  A common routine is given below that can be called with a one line code so that it is easy to implement anywhere and for any number of buttons.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Copy and paste the Code given below into a Global Module of your database and save it.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function AnimateFrame(ByVal OnOff As Boolean, ByVal x_Box As String)&lt;br /&gt;Dim frm As Form, ctrl As Control&lt;br /&gt;On Error GoTo AnimateFrame_Err&lt;br /&gt;&lt;br /&gt;Set frm = Application.Screen.ActiveForm&lt;br /&gt;Set ctrl = frm.Controls(x_Box)&lt;br /&gt;&lt;br /&gt;Select Case OnOff&lt;br /&gt;    Case False&lt;br /&gt;        If ctrl.Visible = False Then Exit Function&lt;br /&gt;        frm.Controls(x_Box).Visible = False&lt;br /&gt;    Case True&lt;br /&gt;        If ctrl.Visible = True Then Exit Function&lt;br /&gt;        frm.Controls(x_Box).Visible = True&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;AnimateFrame_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;AnimateFrame_Err:&lt;br /&gt;Resume AnimateFrame_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, we can replace the code we have written earlier with a single line Code each to display and hide the rectangle.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;     If Me.ExitBox.Visible = False Then&lt;br /&gt;           Me.ExitBox.Visible = True&lt;br /&gt;     End If&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;The above Code can be replaced with the statement &lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt; AnimateFrame True, &amp;quot;ExitBox&amp;quot;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&lt;br /&gt;in the &lt;b&gt;On Mouse Move&lt;/b&gt; of Command Button and &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;&lt;br /&gt;     If Me.ExitBox.Visible = True Then&lt;br /&gt;           Me.ExitBox.Visible = False&lt;br /&gt;     End If&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;can be replaced with the statement &lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt; AnimateFrame False, &amp;quot;ExitBox&amp;quot;&lt;/font&gt; &lt;br&gt;&lt;br&gt;&lt;br /&gt;in the &lt;b&gt;FormFooter_MouseMove&lt;/b&gt; event procedure.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml&amp;title=Command+Button+Animation-2"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/form-menu-bars-and-toolbars.shtml"&gt;Form Menu Bars and Toolbars&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/seriality-control-finding-missing.shtml"&gt;Seriality Control - Missing Numbers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Wave Shaped Reminder Ticker&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;No Data and Report Error&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/lost-links-of-external-tables.shtml"&gt;Lost Links of External Tables&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5976876423197650064?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=9Y_HJVZDSqo:345Q6zy2JGs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=9Y_HJVZDSqo:345Q6zy2JGs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=9Y_HJVZDSqo:345Q6zy2JGs:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=9Y_HJVZDSqo:345Q6zy2JGs:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=9Y_HJVZDSqo:345Q6zy2JGs:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/9Y_HJVZDSqo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/9Y_HJVZDSqo/command-button-animation-2.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/01/command-button-animation-2.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-3240075280454258403</guid><pubDate>Fri, 02 Jan 2009 12:31:00 +0000</pubDate><atom:updated>2009-01-02T17:05:11.142+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess functions</category><title>Cardinal Text Format In Access</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mitEreseQGS0uoOhrDqTLSJ_5pc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mitEreseQGS0uoOhrDqTLSJ_5pc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mitEreseQGS0uoOhrDqTLSJ_5pc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mitEreseQGS0uoOhrDqTLSJ_5pc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;The other day one of my colleagues asked me to open MS-Word and type the expression &lt;font class="colrgreen"&gt;&lt;b&gt;=Rand()&lt;/b&gt; &lt;/font&gt;on a separate line and press &lt;b&gt;Enter&lt;/b&gt; key. It was a magic that I didn&amp;#39;t know till that time.  The following sentence appears fifteen times repeatedly (in 3 rows and 5 columns) overwriting the expression itself:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;The quick brown fox jumps over the lazy dog.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Open a Document in MS-Word and try it out yourself.  The above sentence has all the letters of Alphabet in it.  You can control the printing by inputting parameters to the &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;Function&lt;/a&gt; like &lt;b&gt;=Rand(5,1)&lt;/b&gt; will print the same sentence in 5 lines in one Column. It is a built-in Function with different constructs that can accept different set of parameters and looks like created for fun, I think! It works only when you type it on a separate line.  Even though it looks like a Random Function it has nothing to do with it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;There is another feature in MS-Word that, I like to see in MS-Access, formats numeric values in Cardinal Text.&lt;br&gt; &lt;br /&gt;&lt;br /&gt;For example, result of the &lt;a href="http://www.msaccesstips.com/2007/10/ms-access-and-mail-merge-3.shtml"&gt;Mail Merge&lt;/a&gt; formula &lt;font class="colrgreen"&gt;{ = 9.20 + 5.35 \* CardText } &lt;/font&gt;outputs &lt;b&gt;fourteen and 55/100&lt;/b&gt;, when the document is merged into another Document or to Printer.  Format switches can be either &lt;b&gt;\* DollarText&lt;/b&gt; or &lt;b&gt;\* CardText&lt;/b&gt; to get the above output. When the &lt;b&gt;\* Caps&lt;/b&gt; switch is added to it, like &lt;font class="colrgreen"&gt;{ = 9.20 + 5.35 \* DollarText \* Caps} &lt;/font&gt;, then it changes the first letter of each word into upper case.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is very useful for printing Invoice values in MS-Access. I have written a Function to achieve this in MS-Access and here it is for you to try it out.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Copy and Paste the following Code into a Global Module of your Database and save it:&lt;br&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Public Function CardText(ByVal inNumber As Double, Optional ByVal precision As Integer = 2) As String&lt;br /&gt;'------------------------------------------------------------------------&lt;br /&gt;'Author : a.p.r. pillai&lt;br /&gt;'Date   : December 2008&lt;br /&gt;'URL    : www.msaccesstips.com&lt;br /&gt;'All Rights Reserved by www.msaccesstips.com&lt;br /&gt;'------------------------------------------------------------------------&lt;br /&gt;Dim ctu(0 To 19) As String, ctt(0 To 9) As String, bmth(0 To 4) As String&lt;br /&gt;Dim strNum As String, j As Integer, k As Integer, fmt As String&lt;br /&gt;Dim h As Integer, xten As Integer, yten As Integer&lt;br /&gt;Dim cardseg(1 To 4) As String, txt As String, d As String, txt2 As String&lt;br /&gt;Dim locn As Integer, xfract As String, xhundred As String&lt;br /&gt;&lt;br /&gt;On Error GoTo CardText_Err&lt;br /&gt;&lt;br /&gt;strNum = Trim(Str(inNumber))&lt;br /&gt;locn = InStr(1, strNum, &amp;quot;.&amp;quot;)&lt;br /&gt;'Check Decimal Places and rounding&lt;br /&gt;If locn &amp;gt; 0 Then&lt;br /&gt;  xfract = Mid(strNum, locn + 1)&lt;br /&gt; strNum = Left(strNum, locn - 1)&lt;br /&gt;    If precision &amp;gt; 0 Then&lt;br /&gt;        If Len(xfract) &amp;lt; precision Then&lt;br /&gt;            xfract = xfract &amp;amp; String$(precision - Len(xfract), &amp;quot;0&amp;quot;)&lt;br /&gt;        ElseIf Len(xfract) &amp;gt; precision Then&lt;br /&gt;            xfract = Format(Int(Val(Left(xfract, precision + 1)) / 10 + 0.5), _&lt;br /&gt;            String$(precision, &amp;quot;0&amp;quot;))&lt;br /&gt;        End If&lt;br /&gt;        xfract = IIf(Val(xfract) &amp;gt; 0, xfract &amp;amp; "/" &amp;amp; 10 ^ precision, &amp;quot;&amp;quot;)&lt;br /&gt;    Else&lt;br /&gt;        strNum = Val(strNum) + Int(Val(&amp;quot;.&amp;quot; &amp;amp; xfract) + 0.5)&lt;br /&gt;        xfract = &amp;quot;&amp;quot;&lt;br /&gt;    End If&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;h = Len(strNum)&lt;br /&gt;If h &amp;gt; 12 Then&lt;br /&gt;   'if more than 12 digits take only 12 (max. 999 Billion)&lt;br /&gt;   'extra value will get truncated from left.&lt;br /&gt;   strNum = Right(strNum, 12)&lt;br /&gt;Else&lt;br /&gt;   strNum = String$(12 - h, &amp;quot;0&amp;quot;) &amp;amp; strNum&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;GoSub initSection&lt;br /&gt;&lt;br /&gt;txt2 = &amp;quot;&amp;quot;&lt;br /&gt;For j = 1 To 4&lt;br /&gt;    If Val(cardseg(j)) = 0 Then GoTo NextStep&lt;br /&gt;    txt = &amp;quot;&amp;quot;&lt;br /&gt;    For k = 3 To 1 Step -1&lt;br /&gt;      Select Case k&lt;br /&gt;        Case 3&lt;br /&gt;            xten = Val(Mid(cardseg(j), k - 1, 1))&lt;br /&gt;            If xten = 1 Then&lt;br /&gt;                txt = ctu(10 + Val(Mid(cardseg(j), k, 1)))&lt;br /&gt;            Else&lt;br /&gt;                txt = ctt(xten) &amp;amp; ctu(Val(Mid(cardseg(j), k, 1)))&lt;br /&gt;            End If&lt;br /&gt;        Case 1&lt;br /&gt;            yten = Val(Mid(cardseg(j), k, 1))&lt;br /&gt;            xhundred = ctu(yten) &amp;amp; IIf(yten &gt; 0, bmth(1), &amp;quot;&amp;quot;) &amp;amp; txt&lt;br /&gt;            Select Case j&lt;br /&gt;                Case 2&lt;br /&gt;                    d = bmth(2)&lt;br /&gt;                Case 3&lt;br /&gt;                    d = bmth(3)&lt;br /&gt;                Case 4&lt;br /&gt;                    d = bmth(4)&lt;br /&gt;            End Select&lt;br /&gt;            txt2 = xhundred &amp;amp; d &amp;amp; txt2&lt;br /&gt;    End Select&lt;br /&gt;   Next&lt;br /&gt;NextStep:&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;If Len(txt2) = 0 And Len(xfract) &gt; 0 Then&lt;br /&gt;    txt2 = xfract &amp;amp; &amp;quot; only. &amp;quot;&lt;br /&gt;ElseIf Len(txt2) = 0 And Len(xfract) = 0 Then&lt;br /&gt;    txt2 = &amp;quot;&amp;quot;&lt;br /&gt;Else&lt;br /&gt;  txt2 = txt2 &amp;amp; IIf(Len(xfract) &amp;gt; 0, &amp;quot; and&amp;quot; &amp;amp; xfract, &amp;quot;&amp;quot;) &amp;amp; &amp;quot; only.&amp;quot;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;CardText = txt2&lt;br /&gt;&lt;br /&gt;CardText_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;initSection:&lt;br /&gt;ctu(0) = &amp;quot;&amp;quot;&lt;br /&gt;ctu(1) = &amp;quot; One&amp;quot;&lt;br /&gt;ctu(2) = &amp;quot; Two&amp;quot;&lt;br /&gt;ctu(3) = &amp;quot; Three&amp;quot;&lt;br /&gt;ctu(4) = &amp;quot; Four&amp;quot;&lt;br /&gt;ctu(5) = &amp;quot; Five&amp;quot;&lt;br /&gt;ctu(6) = &amp;quot; Six&amp;quot;&lt;br /&gt;ctu(7) = &amp;quot; Seven&amp;quot;&lt;br /&gt;ctu(8) = &amp;quot; Eight&amp;quot;&lt;br /&gt;ctu(9) = &amp;quot; Nine&amp;quot;&lt;br /&gt;ctu(10) = &amp;quot; Ten&amp;quot;&lt;br /&gt;ctu(11) = &amp;quot; Eleven&amp;quot;&lt;br /&gt;ctu(12) = &amp;quot; Twelve&amp;quot;&lt;br /&gt;ctu(13) = &amp;quot; Thirteen&amp;quot;&lt;br /&gt;ctu(14) = &amp;quot; Fourteen&amp;quot;&lt;br /&gt;ctu(15) = &amp;quot; Fifteen&amp;quot;&lt;br /&gt;ctu(16) = &amp;quot; Sixteen&amp;quot;&lt;br /&gt;ctu(17) = &amp;quot; Seventeen&amp;quot;&lt;br /&gt;ctu(18) = &amp;quot; Eighteen&amp;quot;&lt;br /&gt;ctu(19) = &amp;quot; Nineteen&amp;quot;&lt;br /&gt;&lt;br /&gt;ctt(0) = &amp;quot;&amp;quot;&lt;br /&gt;ctt(1) = &amp;quot; Ten&amp;quot;&lt;br /&gt;ctt(2) = &amp;quot; Twenty&amp;quot;&lt;br /&gt;ctt(3) = &amp;quot; Thirty&amp;quot;&lt;br /&gt;ctt(4) = &amp;quot; Fourty&amp;quot;&lt;br /&gt;ctt(5) = &amp;quot; Fifty&amp;quot;&lt;br /&gt;ctt(6) = &amp;quot; Sixty&amp;quot;&lt;br /&gt;ctt(7) = &amp;quot; Seventy&amp;quot;&lt;br /&gt;ctt(8) = &amp;quot; Eighty&amp;quot;&lt;br /&gt;ctt(9) = &amp;quot; Ninety&amp;quot;&lt;br /&gt;&lt;br /&gt;bmth(0) = &amp;quot;&amp;quot;&lt;br /&gt;bmth(1) = &amp;quot; Hundred&amp;quot;&lt;br /&gt;bmth(2) = &amp;quot; Thousand&amp;quot;&lt;br /&gt;bmth(3) = &amp;quot; Million&amp;quot;&lt;br /&gt;bmth(4) = &amp;quot; Billion&amp;quot;&lt;br /&gt;&lt;br /&gt;cardseg(4) = Mid(strNum, 1, 3)&lt;br /&gt;cardseg(3) = Mid(strNum, 4, 3)&lt;br /&gt;cardseg(2) = Mid(strNum, 7, 3)&lt;br /&gt;cardseg(1) = Mid(strNum, 10, 3)&lt;br /&gt;Return&lt;br /&gt;&lt;br /&gt;CardText_Err:&lt;br /&gt;CardText = &amp;quot;&amp;quot;&lt;br /&gt;MsgBox Err.Description, , &amp;quot;CardText()&amp;quot;&lt;br /&gt;Resume CardText_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The Function name &lt;b&gt;CardText()&lt;/b&gt; is derived from MS-Word Number Format Switch &lt;b&gt;\* CardText. The CardText() &lt;/b&gt;Function can accept a maximum value of &lt;b&gt;10^12-1 &lt;/b&gt; or up to 999 Billion. For most applications this will be sufficient. Passing a Value greater than this will get truncated from left.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;CardText()&lt;/b&gt; Function accepts two parameters and the second one is Optional.  The second parameter controls the number of digits after decimal places. &lt;br /&gt; &lt;br /&gt;By default the &lt;b&gt;CardText()&lt;/b&gt; Function will round-off fractional part, if present, to two decimal places when second parameter is omitted. &lt;br /&gt;&lt;br /&gt;To try out the Code you may open &lt;i&gt;VBA Editing Window&lt;/i&gt; (&lt;b&gt;Alt+F11&lt;/b&gt;) and open &lt;i&gt;Immediate Window&lt;/i&gt; (&lt;b&gt;Ctrl+G&lt;/b&gt;) and type the following statement or similar one with different Value or Expression:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example:&lt;/b&gt; &lt;font class="colrgreen"&gt;? CardText(1234.5678,3)&lt;/font&gt; will produce the result shown below.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Result:&lt;/b&gt; One Thousand Two Hundred Thirty Four and 568/1000 only.&lt;br /&gt;&lt;br /&gt;The first parameter can be a Number or an Expression that &lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;evaluates&lt;/a&gt; to a Numeric Value.  &lt;br /&gt;&lt;br /&gt;If the second parameter is zero then the Number is rounded to the next highest Integer.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example:&lt;/b&gt; &lt;font class="colrgreen"&gt;? CardText(1234.5678,0)&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Result:&lt;/b&gt; Thousand Two Hundred Thirty Five only.&lt;br /&gt;&lt;br /&gt;To change the output to upper-case or lower-cases letters enclose the CardText() Function in &lt;b&gt;UCase()&lt;/b&gt; or &lt;b&gt;LCase()&lt;/b&gt; built-in function respectively.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example:&lt;/b&gt; &lt;font class="colrgreen"&gt;? UCase(CardText(1234.5678))&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Result:&lt;/b&gt; ONE THOUSAND TWO HUNDRED THIRTY FOUR AND 57/100 ONLY.&lt;br /&gt;&lt;br /&gt;To prefix a Currency Description use the following example:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example:&lt;/b&gt; &lt;font class="colrgreen"&gt;? "Dollars" &amp; CardText(1234.5678)&lt;/font&gt;&lt;br /&gt;   Or&lt;br /&gt; &lt;font class="colrgreen"&gt;="Dollars" &amp; CardText([UnitPrice])&lt;/font&gt; on &lt;a href="http://www.msaccesstips.com/2007/08/saving-data-on-forms-not-in-table.shtml"&gt;Forms&lt;/a&gt; or &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;Reports.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Result:&lt;/b&gt; Dollars One Thousand Two Hundred Thirty Four and 57/100 only.&lt;br /&gt;&lt;br /&gt;You may try the Function on Form or Report with data field Value as input.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;CardText()&lt;/b&gt; Function is not extensively field tested and if you find bugs please let me know. Use it at your own risk.&lt;br /&gt;&lt;br /&gt;Any suggestions for improvement are welcome.&lt;br /&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml&amp;title=Cardinal+Text+Format+In+Access"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/seriality-control-finding-missing.shtml"&gt;Seriality Control - Missing Numbers&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Wave Shaped Reminder Ticker&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;No Data and Report Error&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/lost-links-of-external-tables.shtml"&gt;Lost Links of External Tables&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/link-external-tables-with-vba.shtml"&gt;Link External Tables with VBA&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-3240075280454258403?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=NXWxLHwWOwk:7VN0SEQztOc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=NXWxLHwWOwk:7VN0SEQztOc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=NXWxLHwWOwk:7VN0SEQztOc:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=NXWxLHwWOwk:7VN0SEQztOc:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=NXWxLHwWOwk:7VN0SEQztOc:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/NXWxLHwWOwk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/NXWxLHwWOwk/cardinal-text-format-in-access.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2009/01/cardinal-text-format-in-access.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-1371544538773437306</guid><pubDate>Thu, 25 Dec 2008 12:40:00 +0000</pubDate><atom:updated>2008-12-25T17:36:19.807+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess wizards</category><title>Custom Report Wizard</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/X-0SITV_i7yZ3k8uQ3HQiDu8J4o/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/X-0SITV_i7yZ3k8uQ3HQiDu8J4o/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/X-0SITV_i7yZ3k8uQ3HQiDu8J4o/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/X-0SITV_i7yZ3k8uQ3HQiDu8J4o/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;After designing and working with a Form Wizard it is natural to think about designing a Report Wizard too.  Because of the designing task of a Form and Report is almost same, except Page Footer with Page Number and date.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you have gone through the designing task of the Form Wizard then you don&amp;#39;t have to do it again.  Please go through the earlier Post: &lt;a href="http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml"&gt;Custom made Form Wizard &lt;/a&gt;to understand the designing task of the &lt;b&gt;FormWizard&lt;/b&gt; or to download it from there.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Do the following few simple steps and the ReportWizard is ready:&lt;br&gt; &lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Make a copy of the FormWizard and rename it as ReportWizard.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the ReportWizard in Design View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the List Box and Combo Box headings to read as Report Format and Select Table/Query for Report respectively.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the word Form to Report in the left side labels.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the ReportWizard by selecting &lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Code&lt;/b&gt; (or &lt;b&gt;Alt+F11&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Press &lt;b&gt;Ctrl+A&lt;/b&gt; to select the entire Code in the Form Module and press &lt;b&gt;Delete&lt;/b&gt; Key to delete the Code.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy and Paste the Code given below into the ReportWizard Form Module and save the Form:&lt;/li&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Option Compare Database&lt;br /&gt;Option Explicit&lt;br /&gt;Dim DarkBlue As Long, twips As Long, xtyp As Integer, strFile As String&lt;br /&gt;Dim MaxSeq As Integer&lt;br /&gt;Private Sub cmdBack_Click()&lt;br /&gt;   Me.Page1.Visible = True&lt;br /&gt;   Me.Page1.SetFocus&lt;br /&gt;   Me.Page2.Visible = False&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdCancel_Click()&lt;br /&gt;DoCmd.Close acForm, Me.NAME&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdCancel2_Click()&lt;br /&gt;DoCmd.Close acForm, Me.NAME&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdForm_Click()&lt;br /&gt;If xtyp = 1 Then&lt;br /&gt;   Columns&lt;br /&gt;Else&lt;br /&gt;   Tabular&lt;br /&gt;End If&lt;br /&gt;DoCmd.Close acForm, Me.NAME&lt;br /&gt;&lt;br /&gt;cmdForm_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdForm_Click_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;cmdForm_Click&amp;quot;&lt;br /&gt;Resume cmdForm_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdNext_Click()&lt;br /&gt;Dim vizlist As ListBox, lcount As Integer, chkflag As Boolean&lt;br /&gt;Dim FildList As ListBox, strName As String, strRSource As String&lt;br /&gt;Dim cdb As Database, doc As Document&lt;br /&gt;Dim Tbl As TableDef, Qry As QueryDef, QryTyp As Integer&lt;br /&gt;Dim flag As Byte, FieldCount As Integer, j As Integer&lt;br /&gt;&lt;br /&gt;On Error GoTo cmdNext_Click_Err&lt;br /&gt;&lt;br /&gt;Set vizlist = Me.WizList&lt;br /&gt;lcount = vizlist.listcount - 1&lt;br /&gt;&lt;br /&gt;chkflag = False&lt;br /&gt;For j = 0 To lcount&lt;br /&gt;  If vizlist.Selected(j) = True Then&lt;br /&gt;    xtyp = j + 1&lt;br /&gt;    chkflag = True&lt;br /&gt;  End If&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;If IsNull(Me![FilesList]) = True Then&lt;br /&gt;   MsgBox &amp;quot;Select a File from Table/Query List. &amp;quot;, vbOKOnly + vbExclamation, &amp;quot;cmdNext&amp;quot;&lt;br /&gt;   Me.WizList.Selected(0) = True&lt;br /&gt;Else&lt;br /&gt;    strFile = Me!FilesList&lt;br /&gt;&lt;br /&gt;   Me.Page2.Visible = True&lt;br /&gt;   Me.Page2.SetFocus&lt;br /&gt;   Me.Page1.Visible = False&lt;br /&gt;   &lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;flag = 0&lt;br /&gt;For Each Tbl In cdb.TableDefs&lt;br /&gt;    If Tbl.NAME = strFile Then&lt;br /&gt;       flag = 1&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;For Each Qry In cdb.QueryDefs&lt;br /&gt;    If Qry.NAME = strFile Then&lt;br /&gt;       flag = 2&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;If flag = 1 Then&lt;br /&gt;    Set Tbl = cdb.TableDefs(strFile)&lt;br /&gt;    Set FildList = Me.FldList&lt;br /&gt;    strRSource = &amp;quot;&amp;quot;&lt;br /&gt;    FieldCount = Tbl.Fields.Count - 1&lt;br /&gt;    For j = 0 To FieldCount&lt;br /&gt;        If Len(strRSource) = 0 Then&lt;br /&gt;            strRSource = Tbl.Fields(j).NAME&lt;br /&gt;        Else&lt;br /&gt;            strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; Tbl.Fields(j).NAME&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;ElseIf flag = 2 Then&lt;br /&gt;    Set Qry = cdb.QueryDefs(strFile)&lt;br /&gt;    strRSource = &amp;quot;&amp;quot;&lt;br /&gt;    FieldCount = Qry.Fields.Count - 1&lt;br /&gt;    For j = 0 To FieldCount&lt;br /&gt;        If Len(strRSource) = 0 Then&lt;br /&gt;            strRSource = Qry.Fields(j).NAME&lt;br /&gt;        Else&lt;br /&gt;            strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; Qry.Fields(j).NAME&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Me.FldList.RowSource = strRSource&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;cmdNext_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdNext_Click_Err:&lt;br /&gt;MsgBox Err &amp;amp; &amp;quot;: &amp;quot; &amp;amp; Err.Description, , &amp;quot;cmdNext_Click&amp;quot;&lt;br /&gt;Resume cmdNext_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Sub FilesList_NotInList(NewData As String, Response As Integer)&lt;br /&gt;'Not in List&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;Dim strRSource As String, FList As ComboBox&lt;br /&gt;Dim cdb As Database, MaxTables As Integer, rst As Recordset&lt;br /&gt;Dim Tbl As TableDef, Qry As QueryDef, fld As Field&lt;br /&gt;Dim j As Integer, strSQL1 As String, rstcount As Integer&lt;br /&gt;Dim MaxSeq As Integer, mMax&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;&lt;br /&gt;strSQL1 = &amp;quot;SELECT MSysObjects.Name &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;FROM MSysObjects  &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;WHERE (((MSysObjects.Type)=1 Or (MSysObjects.Type)=5) &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;AND ((Left([Name],4))&lt;&gt;'WizQ') AND ((Left([Name],1))&lt;&gt;'~') &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;AND ((MSysObjects.Flags)=0)) &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;ORDER BY MSysObjects.Type, MSysObjects.Name; &amp;quot;&lt;br /&gt;&lt;br /&gt;mMax = 100&lt;br /&gt;DoCmd.Restore&lt;br /&gt;&lt;br /&gt;DarkBlue = 8388608&lt;br /&gt;twips = 1440&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set Qry = cdb.QueryDefs(&amp;quot;WizQuery&amp;quot;)&lt;br /&gt;If Err = 3265 Then&lt;br /&gt;  Set Qry = cdb.CreateQueryDef(&amp;quot;WizQuery&amp;quot;)&lt;br /&gt;  Qry.sql = strSQL1&lt;br /&gt;  cdb.QueryDefs.Append Qry&lt;br /&gt;  cdb.QueryDefs.Refresh&lt;br /&gt;  Err.Clear&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Me.FilesList.RowSource = &amp;quot;WizQuery&amp;quot;&lt;br /&gt;Me.FilesList.Requery&lt;br /&gt;&lt;br /&gt;Form_Open_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;Form_Open_Err:&lt;br /&gt;MsgBox Err &amp;amp; &amp;quot;: &amp;quot; &amp;amp; Err.Description, , &amp;quot;Form_Open&amp;quot;&lt;br /&gt;Resume Form_Open_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdLeft_Click()&lt;br /&gt;LeftAll 1&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdLeftAll_Click()&lt;br /&gt;LeftAll 2&lt;br /&gt;End Sub&lt;br /&gt;Private Sub cmdright_Click()&lt;br /&gt;RightAll 1&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdRightAll_Click()&lt;br /&gt;RightAll 2&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Function Tabular()&lt;br /&gt;Dim cdb As Database, FldList() As String, Ctrl As Control&lt;br /&gt;Dim Rpt As Report, lngTxtLeft As Long, lngTxtTop As Long, lngTxtHeight As Long&lt;br /&gt;Dim Rpttemp As Report, lngLblleft As Long, lngLblTop As Long, lngLblheight As Long&lt;br /&gt;Dim lngtxtwidth As Long, lnglblwidth As Long, FldCheck As Boolean&lt;br /&gt;Dim strTblQry As String, intflds As Integer, lstcount As Long&lt;br /&gt;Dim RptFields As ListBox, j As Integer, mMax&lt;br /&gt;Dim PgSection As Section, DetSection As Section&lt;br /&gt;&lt;br /&gt;'Create Report with Selected Fields&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;&lt;br /&gt;Set RptFields = Me.SelList&lt;br /&gt;lstcount = RptFields.listcount&lt;br /&gt;&lt;br /&gt;If lstcount = 0 Then&lt;br /&gt;   MsgBox &amp;quot;Fields Not Selected for Report! &amp;quot;&lt;br /&gt;   Exit Function&lt;br /&gt;Else&lt;br /&gt;   lstcount = lstcount - 1&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;ReDim FldList(0 To lstcount) As String&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set Rpt = CreateReport&lt;br /&gt;Set PgSection = Rpt.Section(acPageHeader)&lt;br /&gt;    PgSection.Height = 0.6667 * twips&lt;br /&gt;&lt;br /&gt;Set DetSection = Rpt.Section(acDetail)&lt;br /&gt;    DetSection.Height = 0.1667 * twips&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;  FldList(j) = RptFields.ItemData(j)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;With Rpt&lt;br /&gt;    .Caption = strFile&lt;br /&gt;    .RecordSource = strFile&lt;br /&gt;    &lt;br /&gt;    lngtxtwidth = 0.5 * twips&lt;br /&gt;    lngTxtLeft = 0.073 * twips&lt;br /&gt;    lngTxtTop = 0&lt;br /&gt;    lngTxtHeight = 0.1668 * twips&lt;br /&gt;&lt;br /&gt;    lnglblwidth = lngtxtwidth&lt;br /&gt;    lngLblleft = lngTxtLeft&lt;br /&gt;    lngLblTop = 0.5 * twips&lt;br /&gt;    lngLblheight = lngTxtHeight&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;   Set Ctrl = CreateReportControl(Rpt.NAME, acTextBox, acDetail, , FldList(j), lngTxtLeft, lngTxtTop, lngtxtwidth, lngTxtHeight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .ControlSource = FldList(j)&lt;br /&gt;       .ForeColor = DarkBlue&lt;br /&gt;       .BorderColor = DarkBlue&lt;br /&gt;       .BorderStyle = 1&lt;br /&gt;       .NAME = FldList(j)&lt;br /&gt;       lngTxtLeft = lngTxtLeft + (0.5 * twips)&lt;br /&gt;    End With&lt;br /&gt;   &lt;br /&gt;   Set Ctrl = CreateReportControl(Rpt.NAME, acLabel, acPageHeader, , FldList(j), lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .Caption = FldList(j)&lt;br /&gt;       .NAME = FldList(j) &amp;amp; &amp;quot; Label&amp;quot;&lt;br /&gt;       .Width = (0.5 * twips)&lt;br /&gt;       .ForeColor = DarkBlue&lt;br /&gt;       .BorderColor = DarkBlue&lt;br /&gt;       .BorderColor = 0&lt;br /&gt;       .BorderStyle = 1&lt;br /&gt;       .FontWeight = 700 ' Bold&lt;br /&gt;       lngLblleft = lngLblleft + (0.5 * twips)&lt;br /&gt;    End With&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;lnglblwidth = 4.5 * twips&lt;br /&gt;lngLblleft = 0.073 * twips&lt;br /&gt;lngLblTop = 0.0521 * twips&lt;br /&gt;lngLblheight = 0.323 &amp; twips&lt;br /&gt;lnglblwidth = 4.5 &amp;amp; twips&lt;br /&gt; Set Ctrl = CreateReportControl(Rpt.NAME, acLabel, acPageHeader, , &amp;quot;Head1&amp;quot;, lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;   With Ctrl&lt;br /&gt;        .Caption = strFile&lt;br /&gt;        .TextAlign = 2&lt;br /&gt;        .Width = 4.5 * twips&lt;br /&gt;        .Height = 0.38 * twips&lt;br /&gt;        .ForeColor = DarkBlue&lt;br /&gt;        .BorderStyle = 0&lt;br /&gt;        .BorderColor = DarkBlue&lt;br /&gt;        .FontName = &amp;quot;Times New Roman&amp;quot;&lt;br /&gt;        .FontSize = 16&lt;br /&gt;        .FontWeight = 700 ' Bold&lt;br /&gt;        .FontItalic = True&lt;br /&gt;        .FontUnderline = True&lt;br /&gt;   End With&lt;br /&gt;On Error GoTo Tabular_Err&lt;br /&gt;&lt;br /&gt;Page_Footer Rpt&lt;br /&gt;&lt;br /&gt;DoCmd.OpenReport Rpt.NAME, acViewPreview&lt;br /&gt;&lt;br /&gt;Tabular_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;Tabular_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Tabular&amp;quot;&lt;br /&gt;Resume Tabular_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Function Columns()&lt;br /&gt;Dim cdb As Database, FldList() As String, Ctrl As Control&lt;br /&gt;Dim Rpt As Report, lngTxtLeft As Long, lngTxtTop As Long, lngTxtHeight As Long&lt;br /&gt;Dim lngLblleft As Long, lngLblTop As Long, lngLblheight As Long&lt;br /&gt;Dim lngtxtwidth As Long, lnglblwidth As Long, FldCheck As Boolean&lt;br /&gt;Dim strTblQry As String, intflds As Integer, lstcount As Long&lt;br /&gt;Dim FrmFields As ListBox, j As Integer, mMax&lt;br /&gt;Dim HdSection As Section, DetSection As Section&lt;br /&gt;&lt;br /&gt;'Create Report with Selected Fields&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;&lt;br /&gt;Set FrmFields = Me.SelList&lt;br /&gt;lstcount = FrmFields.listcount&lt;br /&gt;&lt;br /&gt;If lstcount = 0 Then&lt;br /&gt;   MsgBox &amp;quot;Fields Not Selected for Report! &amp;quot;&lt;br /&gt;   Exit Function&lt;br /&gt;Else&lt;br /&gt;   lstcount = lstcount - 1&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;ReDim FldList(0 To lstcount) As String&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set Rpt = CreateReport&lt;br /&gt;&lt;br /&gt;Set HdSection = Rpt.Section(acPageHeader)&lt;br /&gt;    HdSection.Height = 0.6667 * twips&lt;br /&gt;&lt;br /&gt;Set DetSection = Rpt.Section(acDetail)&lt;br /&gt;    DetSection.Height = 0.166 * twips&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;  FldList(j) = FrmFields.ItemData(j)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;With Rpt&lt;br /&gt;    .Caption = strFile&lt;br /&gt;    .RecordSource = strFile&lt;br /&gt;    lngtxtwidth = 1.5 * twips&lt;br /&gt;    lngTxtLeft = 1.1 * twips&lt;br /&gt;    lngTxtTop = 0.0417 * twips&lt;br /&gt;    lngTxtHeight = 0.2181 * twips&lt;br /&gt;&lt;br /&gt;    lnglblwidth = lngtxtwidth&lt;br /&gt;    lngLblleft = 0.073 * twips&lt;br /&gt;    lngLblTop = 0.0417 * twips&lt;br /&gt;    lngLblheight = 0.2181 * twips&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;&lt;br /&gt;   Set Ctrl = CreateReportControl(Rpt.NAME, acTextBox, acDetail, , FldList(j), lngTxtLeft, lngTxtTop, lngtxtwidth, lngTxtHeight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .ControlSource = FldList(j)&lt;br /&gt;       .FontName = &amp;quot;Verdana&amp;quot;&lt;br /&gt;       .FontSize = 8&lt;br /&gt;       .FontWeight = 700&lt;br /&gt;       .ForeColor = DarkBlue&lt;br /&gt;       .BorderColor = DarkBlue&lt;br /&gt;       .NAME = FldList(j)&lt;br /&gt;       .BackColor = RGB(255, 255, 255)&lt;br /&gt;       .BorderStyle = 1&lt;br /&gt;       .SpecialEffect = 0&lt;br /&gt;       If (j / 9) = 1 Or (j / 9) = 2 Or (j / 9) = 3 Then&lt;br /&gt;        lngTxtTop = (0.0417 * twips)&lt;br /&gt;        lngTxtLeft = lngTxtLeft + (2.7084 * twips)&lt;br /&gt;       Else&lt;br /&gt;        lngTxtTop = lngTxtTop + .Height + (0.1 * twips)&lt;br /&gt;       End If&lt;br /&gt;    End With&lt;br /&gt;&lt;br /&gt;   Set Ctrl = CreateReportControl(Rpt.NAME, acLabel, acDetail, FldList(j), FldList(j), lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .Caption = FldList(j)&lt;br /&gt;       .Height = (0.2181 * twips)&lt;br /&gt;       .NAME = FldList(j) &amp;amp; &amp;quot; Label&amp;quot;&lt;br /&gt;       .Width = twips&lt;br /&gt;       .ForeColor = 0&lt;br /&gt;       .BorderStyle = 0&lt;br /&gt;       .FontWeight = 400&lt;br /&gt;       If (j / 9) = 1 Or (j / 9) = 2 Or (j / 9) = 3 Then&lt;br /&gt;        lngLblTop = (0.0417 * twips)&lt;br /&gt;        lngLblleft = lngLblleft + (2.7083 * twips)&lt;br /&gt;       Else&lt;br /&gt;        lngLblTop = lngLblTop + .Height + (0.1 * twips)&lt;br /&gt;       End If&lt;br /&gt;    End With&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;lnglblwidth = 4.5 * twips&lt;br /&gt;lngLblleft = 0.073 * twips&lt;br /&gt;lngLblTop = 0.0521 * twips&lt;br /&gt;lngLblheight = 0.323 &amp; twips&lt;br /&gt;lnglblwidth = 4.5 &amp; twips&lt;br /&gt; Set Ctrl = CreateReportControl(Rpt.NAME, acLabel, acPageHeader, , &amp;quot;Head1&amp;quot;, lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;   With Ctrl&lt;br /&gt;        .Caption = strFile&lt;br /&gt;        .TextAlign = 2&lt;br /&gt;        .Width = 4.5 * twips&lt;br /&gt;        .Height = 0.38 * twips&lt;br /&gt;        .ForeColor = DarkBlue&lt;br /&gt;        .BorderStyle = 0&lt;br /&gt;        .BorderColor = DarkBlue&lt;br /&gt;        .FontName = &amp;quot;Times New Roman&amp;quot;&lt;br /&gt;        .FontSize = 20&lt;br /&gt;        .FontWeight = 700 ' Bold&lt;br /&gt;        .FontItalic = True&lt;br /&gt;        .FontUnderline = True&lt;br /&gt;   End With&lt;br /&gt;   &lt;br /&gt;DoCmd.OpenReport Rpt.NAME, acViewPreview&lt;br /&gt;&lt;br /&gt;Columns_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;Columns_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Columns&amp;quot;&lt;br /&gt;Resume Columns_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Function Page_Footer(ByRef obj)&lt;br /&gt;Dim lngWidth As Long, ctrwidth As Long, ctrlCount As Long&lt;br /&gt;Dim j As Long, cdb As Database&lt;br /&gt;Dim lngleft As Long, lngtop As Long, LineCtrl As Control, Ctrl As Control&lt;br /&gt;Dim rptSection As Section, leftmost As Long, lngheight As Long&lt;br /&gt;Dim rightmost As Long, RightIndx As Integer&lt;br /&gt;'&lt;br /&gt;'Note : The Controls appearing in Detail Section from left to Right&lt;br /&gt;'       is not indexed 0 to nn in the order of placing,&lt;br /&gt;'       instead 1st control placed in the Section has index value 0&lt;br /&gt;'       irrespective of its current position.&lt;br /&gt;'&lt;br /&gt;'On Error GoTo Page_Footer_Err&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set rptSection = obj.Section(acDetail)&lt;br /&gt;&lt;br /&gt;ctrlCount = rptSection.Controls.Count - 1&lt;br /&gt;&lt;br /&gt;lngleft = rptSection.Controls(0).Left&lt;br /&gt;rightmost = rptSection.Controls(0).Left&lt;br /&gt;'indexed 0 control may not be the leftmost control on the Form/Report&lt;br /&gt;'so find the leftmost control's left value&lt;br /&gt;For j = 0 To ctrlCount&lt;br /&gt; leftmost = rptSection.Controls(j).Left&lt;br /&gt; &lt;br /&gt; If leftmost &amp;lt; lngleft Then&lt;br /&gt;   lngleft = leftmost&lt;br /&gt; End If&lt;br /&gt; If leftmost &amp;gt; rightmost Then&lt;br /&gt;   rightmost = leftmost&lt;br /&gt;   RightIndx = j&lt;br /&gt; End If&lt;br /&gt;Next&lt;br /&gt; &lt;br /&gt;lngtop = 0.0208 * 1440&lt;br /&gt;lngWidth = 0: ctrwidth = 0&lt;br /&gt;&lt;br /&gt;   lngWidth = rightmost + rptSection.Controls(RightIndx).Width&lt;br /&gt;   lngWidth = lngWidth - lngleft&lt;br /&gt;   &lt;br /&gt;  Set LineCtrl = CreateReportControl(obj.NAME, acLine, acPageFooter, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, lngleft, lngtop, lngWidth, 0)&lt;br /&gt;  Set Ctrl = LineCtrl&lt;br /&gt;  LineCtrl.BorderColor = 12632256&lt;br /&gt;  LineCtrl.BorderWidth = 2&lt;br /&gt;  LineCtrl.NAME = &amp;quot;ULINE&amp;quot;&lt;br /&gt;  &lt;br /&gt;lngtop = 0.0418 * 1440&lt;br /&gt;lngleft = LineCtrl.Left&lt;br /&gt;lngWidth = 2 * 1440&lt;br /&gt;lngheight = 0.229 * 1440&lt;br /&gt;&lt;br /&gt;'draw PageNo control at the Report footer&lt;br /&gt;Set LineCtrl = CreateReportControl(obj.NAME, acTextBox, acPageFooter, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, lngleft, lngtop, lngWidth, lngheight)&lt;br /&gt;With LineCtrl&lt;br /&gt;   .ControlSource = &amp;quot;='Page : ' &amp; [page] &amp; ' / ' &amp; [pages] &amp;quot;&lt;br /&gt;   .NAME = &amp;quot;PageNo&amp;quot;&lt;br /&gt;   .FontName = &amp;quot;Verdana&amp;quot;&lt;br /&gt;   .FontSize = 10&lt;br /&gt;   .FontWeight = 700&lt;br /&gt;   .TextAlign = 1&lt;br /&gt;End With&lt;br /&gt;'draw Date Control at the right edge of the Line Control&lt;br /&gt;'calculate left position of Date control&lt;br /&gt;&lt;br /&gt;lngleft = (LineCtrl.Left + Ctrl.Width) - lngWidth&lt;br /&gt;Set LineCtrl = CreateReportControl(obj.NAME, acTextBox, acPageFooter, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, lngleft, lngtop, lngWidth, lngheight)&lt;br /&gt;With LineCtrl&lt;br /&gt;   .ControlSource = &amp;quot;='Date : ' &amp; Format(Date(),'dd/mm/yyyy') &amp;quot;&lt;br /&gt;   .NAME = &amp;quot;Dated&amp;quot;&lt;br /&gt;   .FontName = &amp;quot;Verdana&amp;quot;&lt;br /&gt;   .FontSize = 10&lt;br /&gt;   .FontWeight = 700&lt;br /&gt;   .TextAlign = 3&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;Page_Footer_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;Page_Footer_Err:&lt;br /&gt;MsgBox Err.Description, &amp;quot;Page_Footer&amp;quot;&lt;br /&gt;Resume Page_Footer_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Private Function RightAll(ByVal SelectionType As Integer)&lt;br /&gt;Dim FldList As ListBox, SelctList As ListBox, strRSource As String&lt;br /&gt;Dim listcount As Long, j As Long, strRS2 As String&lt;br /&gt;&lt;br /&gt;On Error GoTo RightAll_Err&lt;br /&gt;If SelectionType = 0 Then&lt;br /&gt;   Exit Function&lt;br /&gt;End If&lt;br /&gt;Set FldList = Me.FldList&lt;br /&gt;Set SelctList = Me.SelList&lt;br /&gt;&lt;br /&gt;listcount = FldList.listcount - 1&lt;br /&gt;strRSource = SelctList.RowSource: strRS2 = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Select Case SelectionType&lt;br /&gt;    Case 1&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If FldList.Selected(j) = True Then&lt;br /&gt;                If Len(strRSource) = 0 Then&lt;br /&gt;                    strRSource = FldList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; FldList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            Else&lt;br /&gt;                If Len(strRS2) = 0 Then&lt;br /&gt;                    strRS2 = FldList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRS2 = strRS2 &amp;amp; &amp;quot;;&amp;quot; &amp;amp; FldList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = strRSource&lt;br /&gt;        FldList.RowSource = strRS2&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;    Case 2&lt;br /&gt;&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If Len(strRSource) = 0 Then&lt;br /&gt;                strRSource = FldList.ItemData(j)&lt;br /&gt;            Else&lt;br /&gt;                strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; FldList.ItemData(j)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = strRSource&lt;br /&gt;        FldList.RowSource = &amp;quot;&amp;quot;&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;RightAll_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;RightAll_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;RightAll&amp;quot;&lt;br /&gt;Resume RightAll_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Function LeftAll(ByVal SelectionType As Integer)&lt;br /&gt;Dim FldList As ListBox, SelctList As ListBox, strRSource As String&lt;br /&gt;Dim listcount As Long, j As Long, strRS2 As String&lt;br /&gt;&lt;br /&gt;On Error GoTo LeftAll_Err&lt;br /&gt;&lt;br /&gt;If SelectionType = 0 Then&lt;br /&gt;   Exit Function&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set FldList = Me.FldList&lt;br /&gt;Set SelctList = Me.SelList&lt;br /&gt;&lt;br /&gt;listcount = SelctList.listcount - 1&lt;br /&gt;strRSource = FldList.RowSource: strRS2 = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Select Case SelectionType&lt;br /&gt;    Case 1&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If SelctList.Selected(j) = True Then&lt;br /&gt;                If Len(strRSource) = 0 Then&lt;br /&gt;                    strRSource = SelctList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; SelctList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            Else&lt;br /&gt;                If Len(strRS2) = 0 Then&lt;br /&gt;                    strRS2 = SelctList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRS2 = strRS2 &amp;amp; &amp;quot;;&amp;quot; &amp;amp; SelctList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = strRS2&lt;br /&gt;        FldList.RowSource = strRSource&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;    Case 2&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If Len(strRSource) = 0 Then&lt;br /&gt;                strRSource = SelctList.ItemData(j)&lt;br /&gt;            Else&lt;br /&gt;                strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; SelctList.ItemData(j)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = &amp;quot;&amp;quot;&lt;br /&gt;        FldList.RowSource = strRSource&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;LeftAll_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;LeftAll_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;LeftAll&amp;quot;&lt;br /&gt;Resume LeftAll_Exit&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;li&gt;Open the ReportWizard in Normal View.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select a Table or Query from the Combo Box.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select Tabular Wizard option from above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click OK to load the selected Table/Query Field List and open the List of Fields.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the Fields for the Report from the List Box.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click Finish to create the Report.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Normally, after creating the Report we need to modify the Detail Section Controls to make their sizes according to the data type and field sizes.  After these changes the Report Footer created by the Wizard may not match with the modification that we have made.  But, we already have a solution for this in an earlier Post with the Title: Draw Page Border.  One of the following two Programs presented there can be used for drawing a new Page Footer (after deleting the existing Page Footer) or to resize it after changes made to the Detail Section Controls.&lt;bR&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;DrawPageFooter()&lt;/li&gt;&lt;br /&gt;&lt;li&gt;ReSizePageFooter()&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;There are other Reports related Functions also presented there to make Report Designing tasks easier. You may take a look at them as well.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can create beautiful &lt;b&gt;3D Headings&lt;/b&gt; on the Report or Form with Labels or Text Boxes (Text Box values can be drawn from data Fields).  Take a look at the sample Report Headings created with a &lt;b&gt;3D-Text Creation Wizard&lt;/b&gt;:&lt;br&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://msaccesstips.com/uploaded_images/riportheadings-729284.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 108px;" src="http://msaccesstips.com/uploaded_images/riportheadings-729277.jpg" border="0" alt="3D Headings for Access Report" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;The following four Posts are dedicated for &lt;b&gt;3D Text Styles&lt;/b&gt; and you can download the &lt;b&gt;3D-Text Wizard&lt;/b&gt; from any of them:&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Create 3D Headings on Forms&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/border2d-heading-text.shtml"&gt;Border 2D Heading Text&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/border3d-heading.shtml"&gt;Border 3D Heading&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.msaccesstips.com/2006/09/shadow3d-heading-style.shtml"&gt;Shadow 3D Heading Style&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;After creating the 3D-Text you can customize it by changing the Fonts, Fore-Color and Styles like Bold, Italics or Underline. &lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml&amp;title=Custom+Report+Wizard"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/downloads/2008/12/ReportWizard.zip"&gt;&lt;img src="http://www.msaccesstips.com/images/zip.gif" border="0"&gt;&lt;font size="3" color="Blue"&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/font&gt; - File: &lt;font size="3" color="green"&gt;&lt;b&gt;ReportWizard.zip&lt;/b&gt;&lt;/font&gt; (Size:105K)&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Wave Shaped Reminder Ticker&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;No Data and Report Error&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/lost-links-of-external-tables.shtml"&gt;Lost Links of External Tables&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/link-external-tables-with-vba.shtml"&gt;Link External Tables with VBA&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/source-connect-str-property-and-odbc.shtml"&gt;Source Connect Str Property and ODBC&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-1371544538773437306?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=V81q60ZUNLg:voecyPAh0Wo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=V81q60ZUNLg:voecyPAh0Wo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=V81q60ZUNLg:voecyPAh0Wo:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=V81q60ZUNLg:voecyPAh0Wo:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=V81q60ZUNLg:voecyPAh0Wo:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/V81q60ZUNLg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/V81q60ZUNLg/custom-report-wizard.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2008/12/custom-report-wizard.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-5695247647379248022</guid><pubDate>Fri, 12 Dec 2008 21:29:00 +0000</pubDate><atom:updated>2008-12-25T17:35:23.268+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess wizards</category><title>A Custom Made Form Wizard</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ApCt27yNUYBS8jneM6-G6dShMdE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ApCt27yNUYBS8jneM6-G6dShMdE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ApCt27yNUYBS8jneM6-G6dShMdE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ApCt27yNUYBS8jneM6-G6dShMdE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Want to know how Form &lt;a href="http://www.msaccesstips.com/2006/09/create-3d-headings-on-forms.shtml"&gt;Wizards&lt;/a&gt; work?  We will build one of our own and try it out. Perhaps, you may ask why we should do this when MS-Access already has a &lt;a href="http://www.msaccesstips.com/2007/05/opening-access-forms.shtml"&gt;Form&lt;/a&gt; Wizard.  Very true and I thought on those lines for some time, before I decided to give it a try and create the one that I need.  Mainly for two reasons:&lt;br&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Even though MS-Access creates a &lt;a href="http://www.msaccesstips.com/2007/05/closing-forms.shtml"&gt;Form&lt;/a&gt; on ready to use basis, most of the time we must modify this to make it a better looking one. Needs more time for resizing, shaping and arranging the fields and labels.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;It creates Text Boxes of various sizes and shapes depending on the data type and needs more time to shape it up.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;If you create a Tabular Form using Employee Table from Northwind.mdb sample database, you will know what I am talking about.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Up to Access2000, when the Table or &lt;a href="http://www.msaccesstips.com/2008/02/percentage-on-total-query.shtml"&gt;Query&lt;/a&gt; have more fields then all of them cannot be placed on the 22cm width of the &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-design.shtml"&gt;Form&lt;/a&gt; and ends up in error. Later Versions squeezes the controls to accommodate all the fields on the Form.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is where I thought I need a Wizard to create a Tabular Form with equal sized fields (all fields with half an inch in size) so that we can accommodate more fields on the Form. It will be easier to select all of the fields together, re-size quickly and space them out at one step. Fields which needs more width can be re-sized on a case to case basis later. This way we can save some design time. A Tabular Form image created by the Custom Form Wizard (it looks almost like a &lt;a href="http://www.msaccesstips.com/2008/11/event-trapping-summary-on-datasheet.shtml"&gt;Datasheet&lt;/a&gt;) is given below:&lt;br&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/tabular2_506233-727900.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 147px;" src="http://msaccesstips.com/uploaded_images/tabular2_506233-727878.jpg" border="0" alt="Form Created with Custom Form Wizard" /&gt;&lt;/a&gt;&lt;/center&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The Form Wizard has a simple design and easy to make, except the VBA Programs.  You can download this &lt;b&gt;FormWizard&lt;/b&gt; from the bottom of this Post and check the design, &lt;a href="http://"&gt;Property&lt;/a&gt; settings, VBA Routines etc. An image of the &lt;b&gt;FormWizard&lt;/b&gt; in running mode is given below.  The Wizard can create a simple Form in &lt;b&gt;Column&lt;/b&gt; Format or &lt;b&gt;Tabular&lt;/b&gt; Format.  You can select a Table or Query for the Form from a &lt;a href="http://www.msaccesstips.com/2008/03/refresh-dependant-combo-box-contents.shtml"&gt;Combo Box&lt;/a&gt;.&lt;br&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/formwizardrun-758710.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 270px;" src="http://msaccesstips.com/uploaded_images/formwizardrun-758655.jpg" border="0" alt="Form Wizard in Running Mode" /&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Open a new Form.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Insert a &lt;a href="http://www.msaccesstips.com/2007/06/control-screen-menu-design.shtml"&gt;Tab Control&lt;/a&gt; on the Detail Section of the Form.&lt;/li&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/FormWizard1-719813.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 268px;" src="http://msaccesstips.com/uploaded_images/FormWizard1-719796.jpg" border="0" alt="Form Wizard Design Stage-1" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;li&gt;Select the First Page of the Tab Control and display the Property Sheet (&lt;b&gt;View&lt;/b&gt; - -&gt; &lt;b&gt;Properties&lt;/b&gt;).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the Caption Property Value to &lt;b&gt;Select Table&lt;/b&gt;.  This description now appears on the First Page of the Tab Control.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;a href="http://www.msaccesstips.com/2008/05/selected-list-box-items-and-dynamic.shtml"&gt;List Box&lt;/a&gt; as shown on the design and position its child label on the top and give the &lt;b&gt;Caption&lt;/b&gt; value &lt;b&gt;Form Type&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a Label at the left side of the &lt;a href="http://www.msaccesstips.com/2008/05/create-list-from-another-listbox.shtml"&gt;List Box&lt;/a&gt; and enter the Caption Text as shown.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click on the &lt;a href="http://www.msaccesstips.com/2008/05/list-box-and-date-part-one.shtml"&gt;List Box&lt;/a&gt; and display the Property Sheet.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values as shown below:&lt;/li&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name                :  wizlist&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Row Source Type     :  Value List&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Row Source          :  1;"Form Wizard : Columns";2;"Form Wizard : Tabular"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Count        :  2&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Head         :  No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Width        :  0";1"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Bound Column        :  1&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Turn off the Wizard Tool on the Toolbox. Select the Combo Box Tool and draw a Combo Box as shown, below the List Box, and change the Property Values as given below:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name                    :  FilesList&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Row Source Type         :  Table/Query&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Row Source              :  WizQuery&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Count            :  1&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Width            :  1"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Bound Column            :  1&lt;/li&gt;&lt;br /&gt;&lt;li&gt;List Width              :  1"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Limit to List           :  Yes&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a Label to the left of the Combo Box and change the Caption value as shown.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;a href="http://www.msaccesstips.com/2008/03/double-action-command-button.shtml"&gt;Command Button&lt;/a&gt; below and change the Caption to &lt;b&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create a second &lt;a href="http://www.msaccesstips.com/2008/04/colorfull-command-buttons.shtml"&gt;Command Button&lt;/a&gt; to the right and change the Caption to &lt;b&gt;Cancel&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the second Tab Control and change its Caption property Value to &lt;b&gt;Select Fields&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://msaccesstips.com/uploaded_images/FormWizard2-764501.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 268px;" src="http://msaccesstips.com/uploaded_images/FormWizard2-764498.jpg" border="0" alt="Form Wizard Design Stage-2" /&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Create a &lt;a href="http://www.msaccesstips.com/2008/05/list-box-and-date-part-two.shtml"&gt;List Box&lt;/a&gt; for &lt;b&gt;Field List&lt;/b&gt; and a Second List Box for &lt;b&gt;Selected Fields&lt;/b&gt; side by side as shown on the above design.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select the first List Box at the left, display the Property Sheet and change the Property Values as shown below:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name                :  FldList&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Count        :  1&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Head         :  No&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Column Widths       :  2"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Bound Column        :  1&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Select the second &lt;b&gt;List Box&lt;/b&gt; and change the Name Property to &lt;b&gt;SelList&lt;/b&gt; and change other Properties to the same Values as given above.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create four small &lt;a href="http://www.msaccesstips.com/2008/04/transparent-command-button.shtml"&gt;Command Buttons&lt;/a&gt; between the List Boxes as shown on the design.&lt;/li&gt; &lt;br /&gt;&lt;li&gt;Change their Name property Values as &lt;b&gt;cmdRight&lt;/b&gt;, &lt;b&gt;cmdRightAll&lt;/b&gt;, &lt;b&gt;cmdLeft&lt;/b&gt;., &lt;b&gt;cmdLeftAll&lt;/b&gt; from first Command Button on the top to the fourth one at the bottom respectively.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Change their Caption Property Values with &lt;b&gt;&amp;gt;, &amp;gt;&amp;gt;, &amp;lt; &lt;/b&gt; and &lt;b&gt;&amp;lt;&amp;lt;&lt;/b&gt; symbols as shown.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create three Command Buttons below the List Boxes.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value of the left Command Button to &lt;b&gt;cmdBack&lt;/b&gt; and the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;&amp;lt;&amp;lt;Back&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value of the Command Button in the middle to &lt;b&gt;cmdForm&lt;/b&gt; and the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Finish&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the &lt;b&gt;Name&lt;/b&gt; Property Value of the right side Command Button to &lt;b&gt;cmdCancel2&lt;/b&gt; and the &lt;b&gt;Caption&lt;/b&gt; Property Value to &lt;b&gt;Cancel&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click to the right side of the second page of the Tab Control to select the &lt;b&gt;Tab Control&lt;/b&gt; and display the Property Sheet.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the following Property Values:&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2"&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name            :  TabCtl0&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Back Style      :  Transparent&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Style           :  None&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After setting the last two properties of the Tab Control it disappears and nobody can tell that we have designed the whole Wizard on a Tab Control Object.&lt;br&gt; &lt;br /&gt;&lt;br /&gt;&lt;li&gt;Save the Form (&lt;b&gt;File&lt;/b&gt; - -&gt; &lt;b&gt;Save&lt;/b&gt;) with the name &lt;b&gt;FormWizard&lt;/b&gt;.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;One important step left to complete, copying and pasting the complete VBA Routines into the Form Module of the FormWizard.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Display the Code Module of the Form (&lt;b&gt;View&lt;/b&gt; - -&gt;&lt;b&gt;Code&lt;/b&gt;), while the Form is still in design View, Copy the entire Code given below and Paste it into the Code Module of the Form and save the Form.&lt;/li&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Option Compare Database&lt;br /&gt;Option Explicit&lt;br /&gt;Dim DarkBlue As Long, twips As Long, xtyp As Integer, strFile As String&lt;br /&gt;&lt;br /&gt;Private Sub cmdBack_Click()&lt;br /&gt;   Me!FileList = Null&lt;br /&gt;&lt;br /&gt;   Me.Page1.Visible = True&lt;br /&gt;   Me.Page1.SetFocus&lt;br /&gt;   Me.Page2.Visible = False&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdCancel_Click()&lt;br /&gt;DoCmd.Close acForm, Me.NAME&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdCancel2_Click()&lt;br /&gt;DoCmd.Close acForm, Me.NAME&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdForm_Click()&lt;br /&gt;If xtyp = 1 Then&lt;br /&gt;   Columns&lt;br /&gt;Else&lt;br /&gt;   Tabular&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;DoCmd.Close acForm, Me.NAME&lt;br /&gt;&lt;br /&gt;cmdForm_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdForm_Click_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;cmdForm_Click&amp;quot;&lt;br /&gt;Resume cmdForm_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdNext_Click()&lt;br /&gt;Dim vizlist As ListBox, lcount As Integer, chkflag As Boolean&lt;br /&gt;Dim FildList As ListBox, strName As String, strRSource As String&lt;br /&gt;Dim cdb As Database, doc As Document&lt;br /&gt;Dim Tbl As TableDef, Qry As QueryDef, QryTyp As Integer&lt;br /&gt;Dim flag As Byte, FieldCount As Integer, j As Integer&lt;br /&gt;&lt;br /&gt;On Error GoTo cmdNext_Click_Err&lt;br /&gt;&lt;br /&gt;Set vizlist = Me.WizList&lt;br /&gt;lcount = vizlist.listcount - 1&lt;br /&gt;&lt;br /&gt;chkflag = False&lt;br /&gt;For j = 0 To lcount&lt;br /&gt;  If vizlist.Selected(j) = True Then&lt;br /&gt;    xtyp = j + 1&lt;br /&gt;    chkflag = True&lt;br /&gt;  End If&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;If IsNull(Me![FilesList]) = True Then&lt;br /&gt;   MsgBox &amp;quot;Select a File from Table/Query List. &amp;quot;, vbOKOnly + vbExclamation, &amp;quot;cmdNext&amp;quot;&lt;br /&gt;   Me.WizList.Selected(0) = True&lt;br /&gt;Else&lt;br /&gt;   strFile = Me!FilesList&lt;br /&gt;   Me.Page2.Visible = True&lt;br /&gt;   Me.Page2.SetFocus&lt;br /&gt;   Me.Page1.Visible = False&lt;br /&gt;   &lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;flag = 0&lt;br /&gt;For Each Tbl In cdb.TableDefs&lt;br /&gt;    If Tbl.NAME = strFile Then&lt;br /&gt;       flag = 1&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;For Each Qry In cdb.QueryDefs&lt;br /&gt;    If Qry.NAME = strFile Then&lt;br /&gt;       flag = 2&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;If flag = 1 Then&lt;br /&gt;    Set Tbl = cdb.TableDefs(strFile)&lt;br /&gt;    Set FildList = Me.FldList&lt;br /&gt;    strRSource = &amp;quot;&amp;quot;&lt;br /&gt;    FieldCount = Tbl.Fields.Count - 1&lt;br /&gt;    For j = 0 To FieldCount&lt;br /&gt;        If Len(strRSource) = 0 Then&lt;br /&gt;            strRSource = Tbl.Fields(j).NAME&lt;br /&gt;        Else&lt;br /&gt;            strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; Tbl.Fields(j).NAME&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;ElseIf flag = 2 Then&lt;br /&gt;    Set Qry = cdb.QueryDefs(strFile)&lt;br /&gt;    strRSource = &amp;quot;&amp;quot;&lt;br /&gt;    FieldCount = Qry.Fields.Count - 1&lt;br /&gt;    For j = 0 To FieldCount&lt;br /&gt;        If Len(strRSource) = 0 Then&lt;br /&gt;            strRSource = Qry.Fields(j).NAME&lt;br /&gt;        Else&lt;br /&gt;            strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; Qry.Fields(j).NAME&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Me.FldList.RowSource = strRSource&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;cmdNext_Click_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;cmdNext_Click_Err:&lt;br /&gt;MsgBox Err &amp;amp; &amp;quot;:&amp;quot; &amp;amp; Err.Description, , &amp;quot;cmdNext_Click&amp;quot;&lt;br /&gt;Resume cmdNext_Click_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub FilesList_NotInList(NewData As String, Response As Integer)&lt;br /&gt;'Add item&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub Form_Load()&lt;br /&gt;Dim strRSource As String, FList As ComboBox&lt;br /&gt;Dim cdb As Database, MaxTables As Integer, rst As Recordset&lt;br /&gt;Dim Tbl As TableDef, Qry As QueryDef&lt;br /&gt;Dim j As Integer, strSQL1 As String, rstcount As Integer&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;DoCmd.Restore&lt;br /&gt;&lt;br /&gt;strSQL1 = &amp;quot;SELECT MSysObjects.Name &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;FROM MSysObjects &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;WHERE (((MSysObjects.Type)=1 Or (MSysObjects.Type)=5) &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;AND ((Left([Name],4))&lt;&gt;'WizQ') AND ((Left([Name],1))&lt;&gt;'~') &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;AND ((MSysObjects.Flags)=0)) &amp;quot; _&lt;br /&gt;&amp;amp; &amp;quot;ORDER BY MSysObjects.Type, MSysObjects.Name; &amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DarkBlue = 8388608&lt;br /&gt;twips = 1440&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set Qry = cdb.QueryDefs(&amp;quot;WizQuery&amp;quot;)&lt;br /&gt;If Err = 3265 Then&lt;br /&gt;  Set Qry = cdb.CreateQueryDef(&amp;quot;WizQuery&amp;quot;)&lt;br /&gt;  Qry.sql = strSQL1&lt;br /&gt;  cdb.QueryDefs.Append Qry&lt;br /&gt;  cdb.QueryDefs.Refresh&lt;br /&gt;  Err.Clear&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set FList = Me.FilesList&lt;br /&gt;Me.FilesList.RowSource = &amp;quot;WizQuery&amp;quot;&lt;br /&gt;Me.FilesList.Requery&lt;br /&gt;&lt;br /&gt;Form_Load_Exit:&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;Form_Load_Err:&lt;br /&gt;MsgBox Err &amp;amp; &amp;quot;: &amp;quot; &amp;amp; Err.Description, , &amp;quot;Form_Load&amp;quot;&lt;br /&gt;Resume Form_Load_Exit&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdLeft_Click()&lt;br /&gt;LeftAll 1&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdLeftAll_Click()&lt;br /&gt;LeftAll 2&lt;br /&gt;End Sub&lt;br /&gt;Private Sub cmdright_Click()&lt;br /&gt;RightAll 1&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub cmdRightAll_Click()&lt;br /&gt;RightAll 2&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Public Function Tabular()&lt;br /&gt;'-------------------------------------------------------------------&lt;br /&gt;'Author : a.p.r. pillai&lt;br /&gt;'Date   : Sept-2000&lt;br /&gt;'URL    : www.msaccesstips.com&lt;br /&gt;'All Rights Reserved by www.msaccesstips.com&lt;br /&gt;'-------------------------------------------------------------------&lt;br /&gt;Dim cdb As Database, FldList() As String, Ctrl As Control&lt;br /&gt;Dim frm As Form, lngTxtLeft As Long, lngTxtTop As Long, lngTxtHeight As Long&lt;br /&gt;Dim lngLblleft As Long, lngLblTop As Long, lngLblheight As Long&lt;br /&gt;Dim lngtxtwidth As Long, lnglblwidth As Long, FldCheck As Boolean&lt;br /&gt;Dim strTblQry As String, intflds As Integer, lstcount As Long&lt;br /&gt;Dim FrmFields As ListBox, j As Integer&lt;br /&gt;Dim HdSection As Section, DetSection As Section&lt;br /&gt;&lt;br /&gt;'Create Form with Selected Fields&lt;br /&gt;&lt;br /&gt;On Error GoTo Tabular_Err&lt;br /&gt;&lt;br /&gt;Set FrmFields = Me.SelList&lt;br /&gt;lstcount = FrmFields.listcount&lt;br /&gt;&lt;br /&gt;If lstcount = 0 Then&lt;br /&gt;   MsgBox &amp;quot;Fields Not Selected for the Form&amp;quot;&lt;br /&gt;   Exit Function&lt;br /&gt;Else&lt;br /&gt;   lstcount = lstcount - 1&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;ReDim FldList(0 To lstcount) As String&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set frm = CreateForm&lt;br /&gt;Application.RunCommand acCmdFormHdrFtr&lt;br /&gt;&lt;br /&gt;With frm&lt;br /&gt;    .DefaultView = 1&lt;br /&gt;    .ViewsAllowed = 0&lt;br /&gt;    .DividingLines = False&lt;br /&gt;    .Section(acFooter).Visible = True&lt;br /&gt;    .Section(acHeader).DisplayWhen = 0&lt;br /&gt;    .Section(acHeader).Height = 0.5 * 1440&lt;br /&gt;    .Section(acFooter).Height = 0.1667 * 1440&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;Set HdSection = frm.Section(acHeader)&lt;br /&gt;    HdSection.Height = 0.6667 * twips&lt;br /&gt;&lt;br /&gt;Set DetSection = frm.Section(acDetail)&lt;br /&gt;    DetSection.Height = 0.166 * twips&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;  FldList(j) = FrmFields.ItemData(j)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;With frm&lt;br /&gt;    .Caption = strFile&lt;br /&gt;    .RecordSource = strFile&lt;br /&gt;    lngtxtwidth = 0.5 * twips&lt;br /&gt;    lngTxtLeft = 0.073 * twips&lt;br /&gt;    lngTxtTop = 0&lt;br /&gt;    lngTxtHeight = 0.166 * twips&lt;br /&gt;&lt;br /&gt;    lnglblwidth = lngtxtwidth&lt;br /&gt;    lngLblleft = lngTxtLeft&lt;br /&gt;    lngLblTop = 0.5 * twips&lt;br /&gt;    lngLblheight = lngTxtHeight&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;   Set Ctrl = CreateControl(frm.NAME, acTextBox, acDetail, , FldList(j), lngTxtLeft, lngTxtTop, lngtxtwidth, lngTxtHeight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .ControlSource = FldList(j)&lt;br /&gt;       .FontName = &amp;quot;Verdana&amp;quot;&lt;br /&gt;       .Width = (0.5 * twips)&lt;br /&gt;       .FontSize = 8&lt;br /&gt;       .ForeColor = 0&lt;br /&gt;       .BorderColor = 12632256&lt;br /&gt;       .NAME = FldList(j)&lt;br /&gt;       .BackColor = 16777215&lt;br /&gt;       .BorderStyle = 1&lt;br /&gt;       .SpecialEffect = 0&lt;br /&gt;       lngTxtLeft = lngTxtLeft + (0.5 * twips)&lt;br /&gt;    End With&lt;br /&gt;   &lt;br /&gt;   Set Ctrl = CreateControl(frm.NAME, acLabel, acHeader, , FldList(j), lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .Caption = FldList(j)&lt;br /&gt;       .NAME = FldList(j) &amp;amp; &amp;quot; Label&amp;quot;&lt;br /&gt;       .Width = (0.5 * twips)&lt;br /&gt;       .ForeColor = DarkBlue&lt;br /&gt;       .BorderColor = DarkBlue&lt;br /&gt;       .BorderStyle = 1&lt;br /&gt;       .FontWeight = 700 ' Bold&lt;br /&gt;       lngLblleft = lngLblleft + (0.5 * twips)&lt;br /&gt;    End With&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;lnglblwidth = 4.5 * twips&lt;br /&gt;lngLblleft = 0.073 * twips&lt;br /&gt;lngLblTop = 0.0521 * twips&lt;br /&gt;lngLblheight = 0.323 &amp; twips&lt;br /&gt;lnglblwidth = 4.5 &amp; twips&lt;br /&gt; Set Ctrl = CreateControl(frm.NAME, acLabel, acHeader, , &amp;quot;Head1&amp;quot;, lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;   With Ctrl&lt;br /&gt;        .Caption = strFile&lt;br /&gt;        .TextAlign = 2&lt;br /&gt;        .Width = 4.5 * twips&lt;br /&gt;        .Height = 0.38 * twips&lt;br /&gt;        .ForeColor = DarkBlue&lt;br /&gt;        .BorderStyle = 0&lt;br /&gt;        .BorderColor = DarkBlue&lt;br /&gt;        .FontName = &amp;quot;Times New Roman&amp;quot;&lt;br /&gt;        .FontSize = 16&lt;br /&gt;        .FontWeight = 700 ' Bold&lt;br /&gt;        .FontItalic = True&lt;br /&gt;        .FontUnderline = True&lt;br /&gt;   End With&lt;br /&gt;   &lt;br /&gt;DoCmd.OpenForm frm.NAME, acNormal&lt;br /&gt;&lt;br /&gt;Tabular_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;Tabular_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Tabular&amp;quot;&lt;br /&gt;Resume Tabular_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Function Columns()&lt;br /&gt;'-------------------------------------------------------------------&lt;br /&gt;'Author : a.p.r. pillai&lt;br /&gt;'Date   : Sept-2000&lt;br /&gt;'URL    : www.msaccesstips.com&lt;br /&gt;'All Rights Reserved by www.msaccesstips.com&lt;br /&gt;'-------------------------------------------------------------------&lt;br /&gt;Dim cdb As Database, FldList() As String, Ctrl As Control&lt;br /&gt;Dim frm As Form, lngTxtLeft As Long, lngTxtTop As Long, lngTxtHeight As Long&lt;br /&gt;Dim lngLblleft As Long, lngLblTop As Long, lngLblheight As Long&lt;br /&gt;Dim lngtxtwidth As Long, lnglblwidth As Long, FldCheck As Boolean&lt;br /&gt;Dim strTblQry As String, intflds As Integer, lstcount As Long&lt;br /&gt;Dim FrmFields As ListBox, j As Integer&lt;br /&gt;Dim HdSection As Section, DetSection As Section&lt;br /&gt;&lt;br /&gt;'Create Form with Selected Fields&lt;br /&gt;&lt;br /&gt;On Error GoTo Columns_Err&lt;br /&gt;&lt;br /&gt;Set FrmFields = Me.SelList&lt;br /&gt;lstcount = FrmFields.listcount&lt;br /&gt;&lt;br /&gt;If lstcount = 0 Then&lt;br /&gt;   MsgOK &amp;quot;Fields Not Selected for Form&amp;quot;, &amp;quot;FormWizard&amp;quot;&lt;br /&gt;   Exit Function&lt;br /&gt;Else&lt;br /&gt;   lstcount = lstcount - 1&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;ReDim FldList(0 To lstcount) As String&lt;br /&gt;&lt;br /&gt;Set cdb = CurrentDb&lt;br /&gt;Set frm = CreateForm&lt;br /&gt;Application.RunCommand acCmdFormHdrFtr&lt;br /&gt;With frm&lt;br /&gt;    .DefaultView = 0&lt;br /&gt;    .ViewsAllowed = 0&lt;br /&gt;    .DividingLines = False&lt;br /&gt;    .Section(acFooter).Visible = True&lt;br /&gt;    .Section(acHeader).DisplayWhen = 0&lt;br /&gt;    .Section(acHeader).Height = 0.5 * 1440&lt;br /&gt;    .Section(acFooter).Height = 0.1667 * 1440&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;Set HdSection = frm.Section(acHeader)&lt;br /&gt;    HdSection.Height = 0.6667 * twips&lt;br /&gt;&lt;br /&gt;Set DetSection = frm.Section(acDetail)&lt;br /&gt;    DetSection.Height = 0.166 * twips&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;  FldList(j) = FrmFields.ItemData(j)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;With frm&lt;br /&gt;    .Caption = strFile&lt;br /&gt;    .RecordSource = strFile&lt;br /&gt;    lngtxtwidth = 1 * twips&lt;br /&gt;    lngTxtLeft = 1.1 * twips&lt;br /&gt;    lngTxtTop = 0&lt;br /&gt;    lngTxtHeight = 0.166 * twips&lt;br /&gt;&lt;br /&gt;    lnglblwidth = lngtxtwidth&lt;br /&gt;    lngLblleft = 0.073 * twips&lt;br /&gt;    lngLblTop = 0 '0.5 * twips&lt;br /&gt;    lngLblheight = lngTxtHeight&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;For j = 0 To lstcount&lt;br /&gt;&lt;br /&gt;   Set Ctrl = CreateControl(frm.NAME, acTextBox, acDetail, , FldList(j), lngTxtLeft, lngTxtTop, lngtxtwidth, lngTxtHeight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .ControlSource = FldList(j)&lt;br /&gt;       .FontName = &amp;quot;Verdana&amp;quot;&lt;br /&gt;       .FontSize = 8&lt;br /&gt;       .ForeColor = DarkBlue&lt;br /&gt;       .BorderColor = DarkBlue&lt;br /&gt;       .NAME = FldList(j)&lt;br /&gt;       .BackColor = RGB(255, 255, 255)&lt;br /&gt;       .ForeColor = 0&lt;br /&gt;       .BorderColor = 9868950&lt;br /&gt;       .BorderStyle = 1&lt;br /&gt;       .SpecialEffect = 2&lt;br /&gt;       If (j / 9) = 1 Or (j / 9) = 2 Or (j / 9) = 3 Then&lt;br /&gt;        lngTxtTop = 0&lt;br /&gt;        lngTxtLeft = lngTxtLeft + (2.7084 * twips)&lt;br /&gt;       Else&lt;br /&gt;        lngTxtTop = lngTxtTop + .Height + (0.1 * twips)&lt;br /&gt;       End If&lt;br /&gt;    End With&lt;br /&gt;&lt;br /&gt;   Set Ctrl = CreateControl(frm.NAME, acLabel, acDetail, FldList(j), FldList(j), lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;    With Ctrl&lt;br /&gt;       .Caption = FldList(j)&lt;br /&gt;       .NAME = FldList(j) &amp;amp; &amp;quot; Label&amp;quot;&lt;br /&gt;       .Width = twips&lt;br /&gt;       .ForeColor = 0&lt;br /&gt;       .BorderColor = 0&lt;br /&gt;       .BorderColor = 0&lt;br /&gt;       .BorderStyle = 0&lt;br /&gt;       .FontWeight = 400 ' Normal 700 ' Bold&lt;br /&gt;       If (j / 9) = 1 Or (j / 9) = 2 Or (j / 9) = 3 Then&lt;br /&gt;        lngLblTop = 0&lt;br /&gt;        lngLblleft = lngLblleft + (2.7083 * twips)&lt;br /&gt;       Else&lt;br /&gt;        lngLblTop = lngLblTop + .Height + (0.1 * 1440)&lt;br /&gt;       End If&lt;br /&gt;    End With&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;lnglblwidth = 4.5 * twips&lt;br /&gt;lngLblleft = 0.073 * twips&lt;br /&gt;lngLblTop = 0.0521 * twips&lt;br /&gt;lngLblheight = 0.323 &amp; twips&lt;br /&gt;lnglblwidth = 4.5 &amp; twips&lt;br /&gt; Set Ctrl = CreateControl(frm.NAME, acLabel, acHeader, , &amp;quot;Head1&amp;quot;, lngLblleft, lngLblTop, lnglblwidth, lngLblheight)&lt;br /&gt;   With Ctrl&lt;br /&gt;        .Caption = strFile&lt;br /&gt;        .TextAlign = 2&lt;br /&gt;        .Width = 4.5 * twips&lt;br /&gt;        .Height = 0.38 * twips&lt;br /&gt;        .ForeColor = DarkBlue&lt;br /&gt;        .BorderStyle = 0&lt;br /&gt;        .BorderColor = DarkBlue&lt;br /&gt;        .FontName = &amp;quot;Times New Roman&amp;quot;&lt;br /&gt;        .FontSize = 18&lt;br /&gt;        .FontWeight = 700 ' Bold&lt;br /&gt;        .FontItalic = True&lt;br /&gt;        .FontUnderline = True&lt;br /&gt;   End With&lt;br /&gt;   &lt;br /&gt;DoCmd.OpenForm frm.NAME, acNormal&lt;br /&gt;&lt;br /&gt;Columns_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;Columns_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;Columns&amp;quot;&lt;br /&gt;Resume Columns_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Private Function RightAll(ByVal SelectionType As Integer)&lt;br /&gt;Dim FldList As ListBox, SelctList As ListBox, strRSource As String&lt;br /&gt;Dim listcount As Long, j As Long, strRS2 As String&lt;br /&gt;&lt;br /&gt;On Error GoTo RightAll_Err&lt;br /&gt;If SelectionType = 0 Then&lt;br /&gt;   Exit Function&lt;br /&gt;End If&lt;br /&gt;Set FldList = Me.FldList&lt;br /&gt;Set SelctList = Me.SelList&lt;br /&gt;&lt;br /&gt;listcount = FldList.listcount - 1&lt;br /&gt;strRSource = SelctList.RowSource: strRS2 = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Select Case SelectionType&lt;br /&gt;    Case 1&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If FldList.Selected(j) = True Then&lt;br /&gt;                If Len(strRSource) = 0 Then&lt;br /&gt;                    strRSource = FldList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRSource = strRSource &amp;amp; &amp;quot;;&amp;quot; &amp;amp; FldList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            Else&lt;br /&gt;                If Len(strRS2) = 0 Then&lt;br /&gt;                    strRS2 = FldList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRS2 = strRS2 &amp;amp; &amp;quot;;&amp;quot; &amp;amp; FldList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = strRSource&lt;br /&gt;        FldList.RowSource = strRS2&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;    Case 2&lt;br /&gt;&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If Len(strRSource) = 0 Then&lt;br /&gt;                strRSource = FldList.ItemData(j)&lt;br /&gt;            Else&lt;br /&gt;                strRSource = strRSource &amp;amp; &amp;quot;; &amp;quot; &amp;amp; FldList.ItemData(j)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = strRSource&lt;br /&gt;        FldList.RowSource = &amp;quot;&amp;quot;&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;RightAll_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;RightAll_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;RightAll&amp;quot;&lt;br /&gt;Resume RightAll_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Function LeftAll(ByVal SelectionType As Integer)&lt;br /&gt;Dim FldList As ListBox, SelctList As ListBox, strRSource As String&lt;br /&gt;Dim listcount As Long, j As Long, strRS2 As String&lt;br /&gt;&lt;br /&gt;On Error GoTo LeftAll_Err&lt;br /&gt;&lt;br /&gt;If SelectionType = 0 Then&lt;br /&gt;   Exit Function&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set FldList = Me.FldList&lt;br /&gt;Set SelctList = Me.SelList&lt;br /&gt;&lt;br /&gt;listcount = SelctList.listcount - 1&lt;br /&gt;strRSource = FldList.RowSource: strRS2 = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Select Case SelectionType&lt;br /&gt;    Case 1&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If SelctList.Selected(j) = True Then&lt;br /&gt;                If Len(strRSource) = 0 Then&lt;br /&gt;                    strRSource = SelctList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRSource = strRSource &amp;amp; &amp;quot;; &amp;quot; &amp;amp; SelctList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            Else&lt;br /&gt;                If Len(strRS2) = 0 Then&lt;br /&gt;                    strRS2 = SelctList.ItemData(j)&lt;br /&gt;                Else&lt;br /&gt;                    strRS2 = strRS2 &amp;amp; &amp;quot;; &amp;quot; &amp;amp; SelctList.ItemData(j)&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = strRS2&lt;br /&gt;        FldList.RowSource = strRSource&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;    Case 2&lt;br /&gt;        For j = 0 To listcount&lt;br /&gt;            If Len(strRSource) = 0 Then&lt;br /&gt;                strRSource = SelctList.ItemData(j)&lt;br /&gt;            Else&lt;br /&gt;                strRSource = strRSource &amp;amp; &amp;quot;; &amp;quot; &amp;amp; SelctList.ItemData(j)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        SelctList.RowSource = &amp;quot;&amp;quot;&lt;br /&gt;        FldList.RowSource = strRSource&lt;br /&gt;        SelctList.Requery&lt;br /&gt;        FldList.Requery&lt;br /&gt;End Select&lt;br /&gt;&lt;br /&gt;LeftAll_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;LeftAll_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;LeftAll&amp;quot;&lt;br /&gt;Resume LeftAll_Exit&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;NB:&lt;/b&gt; You must ensure that the &lt;b&gt;Name&lt;/b&gt; Property Values of all objects are given correctly to avoid Run time errors.  If you find any of the controls is not working as expected check whether the &lt;b&gt;Name&lt;/b&gt; Property Value is given correctly and the &lt;b&gt;On Click&lt;/b&gt; property is set with the Value &lt;b&gt;[Event Procedure]&lt;/b&gt;. The &lt;b&gt;On Click&lt;/b&gt; Property Value will automatically insert the &lt;b&gt;[Event Procedure]&lt;/b&gt;, if the Name of the control is same as it is referenced in the VBA Routines.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Open the &lt;b&gt;FormWizard&lt;/b&gt; in normal View.  Select one of the Form Design type &lt;b&gt;Column&lt;/b&gt; or &lt;b&gt;Tabular&lt;/b&gt; and select a Table or &lt;a href="http://www.msaccesstips.com/2008/02/crosstab-union-queries-for-charts.shtml"&gt;Query&lt;/a&gt; from the Combo Box below and Click &lt;b&gt;OK&lt;/b&gt;. The List Box will appear with Field Names in the next step.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You can select one or more data fields of your choice and click the button with the &lt;b&gt;&amp;gt;&lt;/b&gt; label to move the selected fields to the right side List Box. You can select all the Fields from the List by clicking on the command button with the &amp;gt;&amp;gt; label.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If you have second thoughts you can Remove the fields from the selected list the same way you selected from the first List Box, using the &lt;b&gt;&amp;lt;&lt;/b&gt; and &lt;b&gt;&amp;lt;&amp;lt;&lt;/b&gt; labeled Command Buttons.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;When you are ready to create the Form click on &lt;b&gt;Finish&lt;/b&gt; Command Button.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;The Form will be created and will open in Normal View. You may Save the Form and change to design view for modifications.&lt;br&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml&amp;title=A+Custom+Made+Form+Wizard"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/downloads/2008/12/FormWizard.zip"&gt;&lt;img src="http://www.msaccesstips.com/images/zip.gif" border="0"&gt;&lt;font size="3" color="Blue"&gt;&lt;b&gt;Download&lt;/b&gt;&lt;/font&gt; - File: &lt;font size="3" color="green"&gt;&lt;b&gt;FormWizard.zip&lt;/b&gt;&lt;/font&gt; (Size:99K)&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/10/wave-shaped-reminder-ticker.shtml"&gt;Wave Shaped Reminder Ticker&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;No Data and Report Error&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/lost-links-of-external-tables.shtml"&gt;Lost Links of External Tables&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/link-external-tables-with-vba.shtml"&gt;Link External Tables with VBA&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/source-connect-str-property-and-odbc.shtml"&gt;Source Connect Str Property and ODBC&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-5695247647379248022?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RywcXIEr0KM:D1Wa4hy5mzE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RywcXIEr0KM:D1Wa4hy5mzE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RywcXIEr0KM:D1Wa4hy5mzE:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=RywcXIEr0KM:D1Wa4hy5mzE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=RywcXIEr0KM:D1Wa4hy5mzE:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/RywcXIEr0KM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/RywcXIEr0KM/custom-made-form-wizard.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.msaccesstips.com/2008/12/custom-made-form-wizard.shtml</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-34083602.post-6067722129153592401</guid><pubDate>Sat, 06 Dec 2008 08:33:00 +0000</pubDate><atom:updated>2008-12-06T13:05:43.133+04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msaccess How Tos</category><title>Rounding Function MRound of Excel</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wYywYwGtwwQtB6ixUQu_npb0Bus/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wYywYwGtwwQtB6ixUQu_npb0Bus/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wYywYwGtwwQtB6ixUQu_npb0Bus/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wYywYwGtwwQtB6ixUQu_npb0Bus/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Normally we round numbers in calculations when the fractional part is &lt;b&gt;0.5&lt;/b&gt; or more to &lt;b&gt;1&lt;/b&gt; (next highest integer) or truncate it altogether.  But, there are times that this fractional part itself to be rounded to a certain level so that it can be used for disbursement of money, like wages.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example, in Currencies when the value ends up in 15 cents, 30 cents they should be rounded to 25 cents, 50 cents respectively for determining the requirement of correct number and denominations of Coins for disbursement.  If we decide we need only 50 Cents Coins then a value of 25 Cents or more should be rounded to 50 Cents and less than 25 Cents to zero.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So, we need a &lt;a href="http://www.msaccesstips.com/2007/09/useful-report-functions.shtml"&gt;function&lt;/a&gt; that can accept a value as precision and find multiples of that value and when the remainder value is half or more of the precision value it should be rounded to the next level. Not necessary that it should be a fractional value it can be any value as precision.&lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;google_ad_client = "pub-2376623373770548";&lt;br /&gt;/* Body468x60, created 10/13/08 */&lt;br /&gt;google_ad_slot = "5564460646";&lt;br /&gt;google_ad_width = 468;&lt;br /&gt;google_ad_height = 60;&lt;br /&gt;//--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&lt;br /&gt;src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;In MS-Access we have &lt;b&gt;Round()&lt;/b&gt; Function that will only round the Double Precision numbers into the required number of Decimal Places or to the next integer level applying the normal rules that we are already familiar. There is a Worksheet Function &lt;b&gt;MRound()&lt;/b&gt; in &lt;a href="http://www.msaccesstips.com/2008/08/opening-excel-database-directly.shtml"&gt;MS-Excel&lt;/a&gt; that can do these kind of calculations, but found nothing like that in MS-Access.  We cannot go to &lt;a href="http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form.shtml"&gt;Excel&lt;/a&gt; when we want this in Access.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We will write a &lt;b&gt;MRound()&lt;/b&gt; Function in Access with the same name.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So here it is:&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt3"&gt;&lt;br /&gt;Public Function MRound(ByVal Number As Double, ByVal Precision As Double) As Double&lt;br /&gt;Dim Y As Double&lt;br /&gt;&lt;br /&gt;On Error GoTo MRound_Err&lt;br /&gt;&lt;br /&gt;   Y = Int(Number / Precision) * Precision&lt;br /&gt;   MRound = IIf(((Number - Y) / Precision * 100 + 0.1) &amp;gt;= 50, Y + Precision, Y)&lt;br /&gt;&lt;br /&gt;MRound_Exit:&lt;br /&gt;Exit Function&lt;br /&gt;&lt;br /&gt;MRound_Err:&lt;br /&gt;MsgBox Err.Description, , &amp;quot;MRound()&amp;quot;&lt;br /&gt;MRound = 0&lt;br /&gt;Resume MRound_Exit&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Copy and paste the above Code into a Global Module of your Database and save the Module.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Open the Debug Window (&lt;b&gt;Ctrl+G&lt;/b&gt;) to try it out directly.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sample Runs:&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(123.3,.2)&lt;/font&gt;&lt;br /&gt;&lt;br /&gt; Result: 123.4&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(123.24,.5) &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Result: 123&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(123.25,.5) &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Result: 123.5&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(123.74,.5) &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Result: 123.5&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(123.75,.5) &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Result: 124&lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(10,3) &lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Result: 9 &lt;br /&gt;&lt;br /&gt;&lt;font class="colrgreen"&gt;? Mround(11,3)&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;Result: 12&lt;br /&gt;&lt;br /&gt;If you would like to share this &lt;a href="http://www.msaccesstips.com/2008/11/sum-min-max-avg-paramarray.shtml"&gt;Function&lt;/a&gt; across your Other MS-Access Databases then create a Library Database with the &lt;a href="http://www.msaccesstips.com/2008/11/custom-calculator-and-eval-function.shtml"&gt;Function&lt;/a&gt; in it and set a &lt;a href="http://www.msaccesstips.com/2006/09/command-button-animation.shtml"&gt;Reference&lt;/a&gt; to the Library Database through &lt;b&gt;&lt;a href="http://www.msaccesstips.com/2007/07/custom-menus-and-tool-bars.shtml"&gt;Tools&lt;/a&gt;&lt;/b&gt;- -&gt;&lt;b&gt;References&lt;/b&gt; in VBA Window.&lt;br&gt;&lt;br /&gt;&lt;div align="right"&gt;&lt;br /&gt;&lt;a href="http://www.stumbleupon.com/submit?url=http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml&amp;title=Rounding+Function+Mround+Of+Excel"&gt;&lt;br /&gt;&lt;img border=0 src="http://www.msaccesstips.com/images/stumbleupon.gif" alt="StumbleUpon Toolbar"&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/no-data-and-report-error.shtml"&gt;No Data and Report Error&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/lost-links-of-external-tables.shtml"&gt;Lost Links of External Tables&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/link-external-tables-with-vba.shtml"&gt;Link External Tables with VBA&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/09/source-connect-str-property-and-odbc.shtml"&gt;Source Connect Str Property and ODBC&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.msaccesstips.com/2008/08/access-live-data-in-excel-2.shtml"&gt;Access Live Data in Excel-2&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2376623373770548";
/* acc468x60footer, created 2/9/09 */
google_ad_slot = "4299616543";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34083602-6067722129153592401?l=www.msaccesstips.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=8zY5Lj_td64:0nz8rg_dWEY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=8zY5Lj_td64:0nz8rg_dWEY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:KwTdNBX3Jqk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=8zY5Lj_td64:0nz8rg_dWEY:KwTdNBX3Jqk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?i=8zY5Lj_td64:0nz8rg_dWEY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?a=8zY5Lj_td64:0nz8rg_dWEY:TzevzKxY174"&gt;&lt;img src="http://feeds.feedburner.com/~ff/LearnMs-accessTipsAndTricks?d=TzevzKxY174" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/LearnMs-accessTipsAndTricks/~4/8zY5Lj_td64" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/LearnMs-accessTipsAndTricks/~3/8zY5Lj_td64/rounding-function-mround-of-excel.shtml</link><author>noreply@blogger.com (a.p.r. pillai)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.msaccesstips.com/2008/12/rounding-function-mround-of-excel.shtml</feedburner:origLink></item></channel></rss>
