<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Darragh Murray &#187; Reports</title>
	<atom:link href="http://www.darraghmurray.com/category/ms-access-tips/reports/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.darraghmurray.com</link>
	<description>Web location of Darragh Murray. Writer with interests in international relations, music, cultural history and Arsenal football club. Home of the UN Internship FAQ.</description>
	<lastBuildDate>Sun, 29 Jan 2012 22:54:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Testing a MS Access subreport for records</title>
		<link>http://www.darraghmurray.com/ms-access-tips/testing-a-ms-access-subreport-for-records/</link>
		<comments>http://www.darraghmurray.com/ms-access-tips/testing-a-ms-access-subreport-for-records/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 03:07:28 +0000</pubDate>
		<dc:creator>Darragh</dc:creator>
				<category><![CDATA[Ms Access Tips]]></category>
		<category><![CDATA[Reports]]></category>
		<category><![CDATA[Ms Access]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.darraghmurray.com/?p=1117</guid>
		<description><![CDATA[I haven&#8217;t done one of these in a long, long time, but I happen to be doing a bit of coding for a friend, and wanted to make a subreport control on an Access report invisible should it have no data. Of course, since I&#8217;ve been mostly out of the Access game for a while [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t done one of these in a long, long time, but I happen to be doing a bit of coding for a friend, and wanted to make a subreport control on an Access report invisible should it have no data. Of course, since I&#8217;ve been mostly out of the Access game for a while now, I was racking my brain for a bit, trying to figure it out and stumbling through a whole bunch of non-working solutions on the net. </p>
<p>But I eventually figured it out&#8230;.</p>
<p>Assuming you have a subreport control on a parent report called MySubReport and you want the subreport control to be not visible should it have no records, this is one option you can use. </p>
<blockquote><p>
Private Sub Report_Activate()<br />
    If Me.MySubReport.Report.HasData = False Then<br />
        Me.MySubReport.Visible = False<br />
    Else<br />
        Me.MySubReport.Visible = True<br />
    End If<br />
End Sub
</p></blockquote>
<p><em><strong>Report.hasData is the key!</strong></em></p>
<p>Many solutions on the Internet talk about using code like this in the IF..THEN expression:</p>
<blockquote><p>
Me.SubReport.Form.RecordSet.RecordCount = 0
</p></blockquote>
<p>Of course, that won&#8217;t work (we&#8217;re working with reports <strong>not forms</strong> and Microsoft inform us that the recordset object isn&#8217;t available in reports. If you try use the above, Access will keep throwing you errors like:</p>
<blockquote><p>
This feature is not available in an MDB.
</p></blockquote>
<p>I&#8217;ve tested this in Access 2007 and it seems to work fine.</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.darraghmurray.com/ms-access-tips/testing-a-ms-access-subreport-for-records/&via=darraghmurray&text=Testing a MS Access subreport for records&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.darraghmurray.com/ms-access-tips/testing-a-ms-access-subreport-for-records/&via=darraghmurray&text=Testing a MS Access subreport for records&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://www.darraghmurray.com/ms-access-tips/testing-a-ms-access-subreport-for-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

