<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Union Query</title>
	<atom:link href="http://msaccesstips.com/2008/02/union-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://msaccesstips.com/2008/02/union-query/</link>
	<description>Free MS-Access downloads</description>
	<lastBuildDate>Fri, 20 Jan 2012 07:03:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Problems creating a report to display totals of several choices in several categories</title>
		<link>http://msaccesstips.com/2008/02/union-query/comment-page-1/#comment-3069</link>
		<dc:creator>Problems creating a report to display totals of several choices in several categories</dc:creator>
		<pubDate>Wed, 10 Aug 2011 07:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://msaccesstips.com/?p=189#comment-3069</guid>
		<description>[...] Union Queries read the following article to avoid unexpected problems creeping into the result:  Union Query     __________________ http://www.msaccesstips.com (Learn MS-Access Tips and Tricks) Learn Advanced [...]</description>
		<content:encoded><![CDATA[<p>[...] Union Queries read the following article to avoid unexpected problems creeping into the result:  Union Query     __________________ <a href="http://www.msaccesstips.com" rel="nofollow">http://www.msaccesstips.com</a> (Learn MS-Access Tips and Tricks) Learn Advanced [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Laptop i7</title>
		<link>http://msaccesstips.com/2008/02/union-query/comment-page-1/#comment-2808</link>
		<dc:creator>Laptop i7</dc:creator>
		<pubDate>Wed, 23 Mar 2011 00:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://msaccesstips.com/?p=189#comment-2808</guid>
		<description>&lt;strong&gt;Computers...&lt;/strong&gt;

We are a group of volunteers and opening a new scheme in our community. Your website provided us with valuable info to work on. You have done an impressive job and our entire community will be thankful to you....</description>
		<content:encoded><![CDATA[<p><strong>Computers&#8230;</strong></p>
<p>We are a group of volunteers and opening a new scheme in our community. Your website provided us with valuable info to work on. You have done an impressive job and our entire community will be thankful to you&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wordpress Themes</title>
		<link>http://msaccesstips.com/2008/02/union-query/comment-page-1/#comment-1523</link>
		<dc:creator>Wordpress Themes</dc:creator>
		<pubDate>Wed, 22 Sep 2010 15:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://msaccesstips.com/?p=189#comment-1523</guid>
		<description>Nice brief and this post helped me alot in my college assignement. Thanks you seeking your information.</description>
		<content:encoded><![CDATA[<p>Nice brief and this post helped me alot in my college assignement. Thanks you seeking your information.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: a.p.r. pillai</title>
		<link>http://msaccesstips.com/2008/02/union-query/comment-page-1/#comment-142</link>
		<dc:creator>a.p.r. pillai</dc:creator>
		<pubDate>Wed, 25 Mar 2009 20:10:34 +0000</pubDate>
		<guid isPermaLink="false">http://msaccesstips.com/?p=189#comment-142</guid>
		<description>Name the Tables in such a way that we can refer them in code easily. I will give you an example involving some SELECT Queries so that it will be more clear than explaining at length.&lt;br /&gt;&lt;br /&gt;We have a P &amp; L System and the User is asked to set a Parameter Screen where she will enter the &lt;b&gt;Month&lt;/b&gt; to prepare the Report for the period she wants.&lt;br /&gt;&lt;br /&gt;All twelve months Select Queries are prepared with the name like &lt;b&gt;CUR_MTH1&lt;/b&gt; to &lt;b&gt;CUR_MTH12&lt;/b&gt; (CUR stands for Current, we have &lt;b&gt;Last-Year&lt;/b&gt; and &lt;b&gt;Budget&lt;/b&gt; Figures created in similar way) and based on the &lt;b&gt;Month&lt;/b&gt; selection we have to assemble the SELECT Queries from Jan to selected Month into a Union Query (&lt;b&gt;CUR_UNION&lt;/b&gt;) before processing.&lt;br /&gt;&lt;br /&gt;Part of the Code used for this purpose is given below:&lt;br /&gt;&lt;br /&gt;Private Function DefineUnion()&lt;br /&gt;&lt;br /&gt;Dim sql0 As String, i As Integer, vI As Integer, sql1 As String&lt;br /&gt;Dim sql As String, db As Database, QryDef As QueryDef&lt;br /&gt;&lt;br /&gt;Me.Refresh&lt;br /&gt;&lt;br /&gt;vI = Me![xMonth] &#039;read Month Param Setting&lt;br /&gt;sql0 = &quot;SELECT CUR_MTH1.* FROM CUR_MTH1&quot; &#039;select January as default&lt;br /&gt;&lt;br /&gt;sql1 = &quot;&quot;&lt;br /&gt;&#039;select Queries to assemble&lt;br /&gt;For i = 2 To vI&lt;br /&gt;    sql1 = sql1 &amp; Chr(13) &amp; Chr(10) _&lt;br /&gt;    &amp; &quot; UNION ALL SELECT &lt;b&gt;CUR_MTH&lt;/b&gt;&quot; &amp; &lt;b&gt;i&lt;/b&gt; &amp; &quot;.* FROM &lt;b&gt;CUR_MTH&lt;/b&gt;&quot; &amp; &lt;b&gt;i&lt;/b&gt;&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;sql = sql0 &amp; sql1 &amp; &quot; ORDER BY FR, BRA,MTH,CAT;&quot;&lt;br /&gt;&lt;br /&gt;&#039;redefine Union Query&lt;br /&gt;Set db = CurrentDb&lt;br /&gt;Set QryDef = db.QueryDefs(&quot;CUR_UNION&quot;)&lt;br /&gt;QryDef.sql = sql&lt;br /&gt;&lt;br /&gt;Set QryDef = Nothing&lt;br /&gt;Set db = Nothing&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;The SQL of the Output Union Query is given below:&lt;br /&gt;&lt;br /&gt;SELECT CUR_MTH1.* FROM CUR_MTH1&lt;br /&gt; UNION ALL SELECT CUR_MTH2.* FROM CUR_MTH2&lt;br /&gt; UNION ALL SELECT CUR_MTH3.* FROM CUR_MTH3&lt;br /&gt;ORDER BY FR, BRA, MTH, CAT;&lt;br /&gt;&lt;br /&gt;In your case the Source is Tables rather than SELECT Queries. The same method can be applied.&lt;br /&gt;&lt;br /&gt;Regards,</description>
		<content:encoded><![CDATA[<p>Name the Tables in such a way that we can refer them in code easily. I will give you an example involving some SELECT Queries so that it will be more clear than explaining at length.</p>
<p>We have a P &#038; L System and the User is asked to set a Parameter Screen where she will enter the <b>Month</b> to prepare the Report for the period she wants.</p>
<p>All twelve months Select Queries are prepared with the name like <b>CUR_MTH1</b> to <b>CUR_MTH12</b> (CUR stands for Current, we have <b>Last-Year</b> and <b>Budget</b> Figures created in similar way) and based on the <b>Month</b> selection we have to assemble the SELECT Queries from Jan to selected Month into a Union Query (<b>CUR_UNION</b>) before processing.</p>
<p>Part of the Code used for this purpose is given below:</p>
<p>Private Function DefineUnion()</p>
<p>Dim sql0 As String, i As Integer, vI As Integer, sql1 As String<br />Dim sql As String, db As Database, QryDef As QueryDef</p>
<p>Me.Refresh</p>
<p>vI = Me![xMonth] &#39;read Month Param Setting<br />sql0 = &quot;SELECT CUR_MTH1.* FROM CUR_MTH1&quot; &#39;select January as default</p>
<p>sql1 = &quot;&quot;<br />&#39;select Queries to assemble<br />For i = 2 To vI<br />    sql1 = sql1 &#038; Chr(13) &#038; Chr(10) _<br />    &#038; &quot; UNION ALL SELECT <b>CUR_MTH</b>&quot; &#038; <b>i</b> &#038; &quot;.* FROM <b>CUR_MTH</b>&quot; &#038; <b>i</b><br />Next</p>
<p>sql = sql0 &#038; sql1 &#038; &quot; ORDER BY FR, BRA,MTH,CAT;&quot;</p>
<p>&#39;redefine Union Query<br />Set db = CurrentDb<br />Set QryDef = db.QueryDefs(&quot;CUR_UNION&quot;)<br />QryDef.sql = sql</p>
<p>Set QryDef = Nothing<br />Set db = Nothing</p>
<p>End Function</p>
<p>The SQL of the Output Union Query is given below:</p>
<p>SELECT CUR_MTH1.* FROM CUR_MTH1<br /> UNION ALL SELECT CUR_MTH2.* FROM CUR_MTH2<br /> UNION ALL SELECT CUR_MTH3.* FROM CUR_MTH3<br />ORDER BY FR, BRA, MTH, CAT;</p>
<p>In your case the Source is Tables rather than SELECT Queries. The same method can be applied.</p>
<p>Regards,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ritesh</title>
		<link>http://msaccesstips.com/2008/02/union-query/comment-page-1/#comment-143</link>
		<dc:creator>Ritesh</dc:creator>
		<pubDate>Tue, 24 Mar 2009 23:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://msaccesstips.com/?p=189#comment-143</guid>
		<description>This is helpful information. How would you use this query when there are hundreds of tables that need to be merged into one?</description>
		<content:encoded><![CDATA[<p>This is helpful information. How would you use this query when there are hundreds of tables that need to be merged into one?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

