<?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>Database Lessons &#187; access</title>
	<atom:link href="http://databaselessons.com/blog/tag/access/feed/" rel="self" type="application/rss+xml" />
	<link>http://databaselessons.com/blog</link>
	<description>Tips for MS Access users</description>
	<lastBuildDate>Tue, 19 Jul 2011 11:48:55 +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>Cascading Queries in a Single Query</title>
		<link>http://databaselessons.com/blog/cascading-queries-in-a-single-query/</link>
		<comments>http://databaselessons.com/blog/cascading-queries-in-a-single-query/#comments</comments>
		<pubDate>Sat, 29 May 2010 10:05:16 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Queries]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[sub-select query]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=130</guid>
		<description><![CDATA[As promised, here is the query within a query solution that simplifies the last article&#8217;s idea. We saw in my last post how a question like &#8220;Who was the first person to borrow a book?&#8221; could be solved by having a query use the results from another query. That required 2 actual queries saved separately. [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is the query within a query solution that simplifies the last article&#8217;s idea.</p>
<p>We saw in my last post how a question like &#8220;Who was the first person to borrow a book?&#8221; could be solved by having a query use the results from another query. That required 2 actual queries saved separately. Now let&#8217;s see that same concept done in a single saved query.</p>
<p>Let&#8217;s break the problem down into steps.</p>
<p>Step 1 &#8211; determine the earliest case of a book being borrowed</p>
<pre>
SELECT Min(tblBorrowing.dtmDateDue) AS EarliestDate
FROM tblBorrowing
WHERE (((tblBorrowing.lngBookID)=1));
</pre>
<p>I have shown the raw SQL above (good idea to learn that stuff!), but you could have just used the query builder to create a query like this following.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook4.jpg" alt="sub-select query part 1" title="sub-select query part 1" width="326" height="257" class="aligncenter size-full wp-image-134" /></p>
<p>Note my use of a custom field name in &#8220;EarliestDate&#8221;.</p>
<p>Step 2 &#8211; Utilize the first query in a where clause</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook5.jpg" alt="final sub-query design" title="final sub-query design" width="498" height="242" class="aligncenter size-full wp-image-136" /></p>
<p>Note how I went back and created the original query style, utilizing all the tables and desired fields, and then added the first query as a criteria for the date field.</p>
<p>This creates a single saved query, rather than 2 separate ones. Here is the resulting (and somewhat hard to read!) SQL code. </p>
<pre>
SELECT tblCustomers.strCustomerName, tblBooks.strBookName,
tblBorrowing.dtmDateDue
FROM (tblBooks INNER JOIN tblBorrowing ON tblBooks.lngBookID =
tblBorrowing.lngBookID) INNER JOIN tblCustomers ON
tblBorrowing.lngCustomerID = tblCustomers.lngCustomerID
WHERE (((tblBooks.lngBookID)=1) AND tblBorrowing.dtmDateDue =
(SELECT Min(tblBorrowing.dtmDateDue) AS EarliestDate
FROM tblBorrowing
WHERE (((tblBorrowing.lngBookID)=1));
));
</pre>
<p>I will admit, however, that I often clutter my databases with the 2 (or more!!!) query solutions as discussed last week. I find them easier to comprehend and fine tune.</p>
<p>If you want a cleaner looking Queries tab, use this sub-select version!</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/cascading-queries-in-a-single-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Query On Query</title>
		<link>http://databaselessons.com/blog/query-on-query/</link>
		<comments>http://databaselessons.com/blog/query-on-query/#comments</comments>
		<pubDate>Sat, 22 May 2010 09:58:50 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Queries]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[cascading queries]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=120</guid>
		<description><![CDATA[Some of my Access Database using readers may not know that a query can use another query for its source. Many of us get into the mindset that a query only reads from a table. So, if I create a new query and choose Design View, the next screen that pops up is called the [...]]]></description>
			<content:encoded><![CDATA[<p>Some of my Access Database using readers may not know that a query can use another query for its source. Many of us get into the mindset that a query only reads from a table.</p>
<p>So, if I create a new query and choose Design View, the next screen that pops up is called the Show Table dialogue box. But look closer. It is not only showing Tables. There are also tabs for Queries and Both.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/newquery.jpg" alt="Add Table Dialogue Box" title="Add Table Dialogue Box" width="372" height="294" class="aligncenter size-full wp-image-121" /></p>
<p>When is this useful?</p>
<p>One of the best examples is a library book borrowing database. Answer questions like this. Who was the first person to borrow the book, &#8220;How to Create a Query&#8221;?</p>
<p>Here are the tables of a simple version of this concept.</p>
<pre>
tblBooks
---------
lngBookID
strBookName

tblCustomers
-------------
lngCustomerID
strCustomerName

tblBorrowing
------------
lngBorrowID
lngBookID
lngCustomerID
dtmDateDue
</pre>
<p>The first thought may be to create a &#8220;Totals&#8221; query that asks for the Min function of the date field. Like this.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook1.jpg" alt="basic query for book lending" title="basic query for book lending" width="485" height="268" class="aligncenter size-full wp-image-123" /></p>
<p>This does not work directly, as it returns the first time that each customer borrowed that book. We just want the very first customer who borrowed the book. We can visually see that it was David Martin, but we want the query to determine this by itself.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook2.jpg" alt="initial who borrowed first query" title="initial who borrowed first query" width="577" height="79" class="aligncenter size-full wp-image-125" /></p>
<p>One solution to this problem follows.</p>
<p>Remove the Customer Name from the first query. Since it is not needed anymore, remove the Customer table as well. The query now returns just one record; that of the first time the book was borrowed. Save that query as qryMinQueryBook, or similar.</p>
<p>Now, start a new query. Add in the query you just created, as well as the Customer table and the Borrowing table. Link the 2 date fields.</p>
<p><img src="http://databaselessons.com/blog/wp-content/uploads/minbook3.jpg" alt="final solution query" title="final solution query" width="430" height="257" class="aligncenter size-full wp-image-127" /></p>
<p>This will produce a single record; that of David Martin.</p>
<p>One term that is used for this method is &#8220;Cascading Queries&#8221;. I have personally used this technique to multiple layers, and horizontally had more than 1 query as well.</p>
<p>In my next article I will show how simple cascading queries like the one above can been done in a single query.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/query-on-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Report With SubTotals and Grand Totals</title>
		<link>http://databaselessons.com/blog/simple-report-with-subtotals-and-grand-totals/</link>
		<comments>http://databaselessons.com/blog/simple-report-with-subtotals-and-grand-totals/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 18:53:26 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[grand total]]></category>
		<category><![CDATA[microsoft access]]></category>
		<category><![CDATA[ms access]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[subtotals]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=109</guid>
		<description><![CDATA[Someone read the post from 2 days ago and took this to a slightly further point. How can I list all the details, and also list subtotals by a subset of the itemID, and then a grand total. They were referring specifically to a report of the data. Here is some fake data I created [...]]]></description>
			<content:encoded><![CDATA[<p>Someone read the post from 2 days ago and took this to a slightly further point.</p>
<p>How can I list all the details, and also list subtotals by a subset of the itemID, and then a grand total. They were referring specifically to a report of the data.</p>
<p>Here is some fake data I created to illustrate.</p>
<pre>
itemid   cost
01142    $1.00
01222    $7.00
01333    $2.00
01623    $4.00
01777    $7.00
01997    $4.00
02456    $8.00
02556    $5.00
02666    $9.00
02716    $8.00
02796    $9.00
02916    $2.00
03455    $5.00
03485    $4.00
03555    $7.00
03675    $7.00
05666    $6.00
05886    $1.00
</pre>
<p>The report should look like this. (plus appropriate headers)</p>
<pre>
itemid   cost
01142    $1.00
01222    $7.00
01333    $2.00
01623    $4.00
01777    $7.00
01997    $4.00
01 subtotal = $25.00
02456    $8.00
02556    $5.00
02666    $9.00
02716    $8.00
02796    $9.00
02916    $2.00
02 subtotal = $41.00
03455    $5.00
03485    $4.00
03555    $7.00
03675    $7.00
03 subtotal = $23.00
05666    $6.00
05886    $1.00
05 subtotal = $7.00

grand total = $96.00
</pre>
<p>Here are the steps needed in Microsoft Access 2000. I am not putting in every small detail, as I believe you should think about what you are doing, and copying every tiny detail from me will not help you.</p>
<ul>
<li>start the report wizard, giving it the name of the table you are needing</li>
<li>select the itemID and cost fields</li>
<li>choose itemID as a grouping field</li>
<li>click the Grouping Options button and choose a Grouping interval of &#8220;2 initial letters&#8221;</li>
<li>no sorting is needed, but under Summary Options you want the Sum of the cost field</li>
<li>pick a style and finish the report&#8217;s creation (Note: give it a proper name, like rptCosts, or similar)</li>
</ul>
<p>The report is not quite what we wanted, but is close.</p>
<p>Next I went into the design view of the wizard created report and &#8230;</p>
<ul>
<li>deleted the &#8220;Summary for &#8230;&#8221; item from the itemID footer</li>
<li>moved the &#8220;Left$ &#8230;&#8221; item from the itemID header to the itemID footer</li>
<li>rearranged the objects in the itemID footer to better emulate the design I wanted</li>
<li>went into the Sorting and Grouping section under the view menu</li>
<li>changed the itemID Group Header to &#8220;No&#8221;</li>
<li>continued to play with formatting until I had it the way I wanted it</li>
</ul>
<p>See printouts, <a href="http://www.databaselessons.com/blog/wp-content/uploads/rptData1.pdf"><strong>before</strong></a> and <a href="http://www.databaselessons.com/blog/wp-content/uploads/rptData1.pdf"><strong>after</strong></a> changes, by clicking on the links in this sentence.</p>
<p>The key in my MS Access self-done education period was to use the wizard like we just did, and look at the design and especially properties of objects, and the Sorting and Grouping dialogue box. I experimented and discovered &#8220;stuff&#8221;.</p>
<p>Hopefully I can help you discover that &#8220;stuff&#8221; faster than I did, but in a way that still helps you &#8220;see&#8221; what is going on. Don&#8217;t ever depend solely on a recipe book. Discover the principles so that you can create your own recipes.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/simple-report-with-subtotals-and-grand-totals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access, FTP, PHP, MySQL &#8211; Part 2</title>
		<link>http://databaselessons.com/blog/access-ftp-php-mysql-part-2/</link>
		<comments>http://databaselessons.com/blog/access-ftp-php-mysql-part-2/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 09:39:38 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=35</guid>
		<description><![CDATA[I have finally resumed my series about using Access on a PC to feed a MySQL database on the web! Read part 2 here. This part describes the purpose of the database and describes 2 of the websites that get fed by this little homegrown system. Remember that this method was created for websites that [...]]]></description>
			<content:encoded><![CDATA[<p>I have finally resumed my series about using Access on a PC to feed a MySQL database on the web! Read <a href="http://www.databaselessons.com/access-ftp-php-mysql-2.php">part 2 here</a>. This part describes the purpose of the database and describes 2 of the websites that get fed by this little homegrown system.</p>
<p>Remember that this method was created for websites that exist on servers that do NOT allow remote MySQL connections. Some servers do allow the remote connections, which simplifies the whole process.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/access-ftp-php-mysql-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Access, PHP, and MySQL</title>
		<link>http://databaselessons.com/blog/access-php-and-mysql/</link>
		<comments>http://databaselessons.com/blog/access-php-and-mysql/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 12:30:15 +0000</pubDate>
		<dc:creator>manxman</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://databaselessons.com/blog/?p=21</guid>
		<description><![CDATA[There are times when I would love to enter data into an MS Access database on my local machine, and then pass that data to a MySQL database on a web site. However, firewall rules normally prevent accessing those databases from outside the network where the respective server machines are located. How can I get [...]]]></description>
			<content:encoded><![CDATA[<p>There are times when I would love to enter data into an MS Access database on my local machine, and then pass that data to a MySQL database on a web site. However, firewall rules normally prevent accessing those databases from outside the network where the respective server machines are located.</p>
<p>How can I get around this?</p>
<p>In researching this question, one reasonably simple answer is to have a small slave program on the website that hosts the MySQL database. Your MS Access database then passes the data to this slave, which then adds the data to the database on the internet.</p>
<p>Specifically, the approach I took is this.</p>
<ul>
<li>enter data into MS Access database on local machine</li>
<li>Access exports data to a text file (or you could get fancy and do XML output)</li>
<li>Access initiates an FTP command which transfer the text file to the website</li>
<li>Access initiates the slave program on the website</li>
<li>slave program reads the uploaded text file and inserts data into the MySQL database</li>
<li>text file is deleted from the website</li>
</ul>
<p>The slave program is created using PHP.</p>
<p>Next posting will start a series that will give more details. In the meantime, you may want to play with this idea on your own and then compare with my solution later.</p>
<p>This posting also exists as an article on the main site. See it <a href="http://www.databaselessons.com/access-ftp-php-mysql-1.php">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://databaselessons.com/blog/access-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

