<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Help me create a database to give money away</title>
	<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away/</link>
	<description>Comments on Ask MetaFilter post Help me create a database to give money away</description>
	<pubDate>Wed, 16 Jan 2008 15:35:00 -0800</pubDate>
	<lastBuildDate>Wed, 16 Jan 2008 15:35:00 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Help me create a database to give money away</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away</link>	
		<description>Help me design a small Access application to run a prize drawing.  As I see it, the MC will open the application and click the Draw button, which will select from the available prizes for that month.  Once drawn, that prize becomes unavailable.  MC will then type in the winner&apos;s name and click Save, setting the form ready for the next contestant.

Specs and examples follow. &lt;br /&gt;&lt;br /&gt; Prizes will be one of the following dollar denominations: 5, 10, 20, 50, 100, or Consolation Prize.&lt;br&gt;
&lt;br&gt;
There may be more than one prize of a particular denomination, that will change from month to month.&lt;br&gt;
&lt;br&gt;
Prizes should be chosen randomly.&lt;br&gt;
&lt;br&gt;
Prizes cannot be given more than once.  (obvious)&lt;br&gt;
&lt;br&gt;
As an example, this months drawing may have 12 $5 prizes, 9 $10 prizes, 5 $20 prizes, 2 $50 prizes, 1 $100 prize, and 50 consolation prizes.&lt;br&gt;
&lt;br&gt;
The application will need to be opened and closed a few times before the month&apos;s drawing is complete.  Freeware applicaitons that interface with Access or Excel will be considered.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.81186</guid>
		<pubDate>Wed, 16 Jan 2008 14:41:03 -0800</pubDate>
		<dc:creator>kc0dxh</dc:creator>
		
			<category>Access</category>
		
			<category>Drawing</category>
		
			<category>Contest</category>
		
			<category>Raffle</category>
		
			<category>Prize</category>
		
			<category>Database</category>
		
	</item> <item>
		<title>By: i love cheese</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204032</link>	
		<description>I&apos;m not sure what your question is, but it seems like a straightforward project that can be done entirely in Access (or Excel) by someone with some VBA programming skill in less than a day.  In Access you would want a table for the prizes and a table for winners.  If the list of potential winners is known (e.g., if it is an employee roster), then you would have a table listing all the eligible people.&lt;br&gt;
&lt;br&gt;
Here&apos;s what it could look like:&lt;br&gt;
&lt;br&gt;
Table: Prizes&lt;br&gt;
ID, Description, DateAwarded&lt;br&gt;
&lt;br&gt;
Table: People&lt;br&gt;
ID, Name&lt;br&gt;
&lt;br&gt;
Table: PrizeWinners&lt;br&gt;
ID, PrizeID, PeopleID, DateAwarded&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The &apos;ID&apos; field in each table would be a unique primary key.&lt;br&gt;
&lt;br&gt;
You would then populate the Prizes and People tables, assigning a unique ID to each record.&lt;br&gt;
&lt;br&gt;
Then, create a relation between the three tables so that the ID fields in the Prizes and People tables each are linked to the obvious fields in the PrizeWinners table.&lt;br&gt;
&lt;br&gt;
Finally, create a form that has a button that first queries the Prize table with SQL like &quot;SELECT * FROM Prizes WHERE DateAwarded IsNull;&quot;  (I&apos;m not sure if you would use IsNull or something like =&quot;&quot; or something else).  Using the returned recordset, you would select a random number between 1 and recordset.recordcount.  The random number would be the record number, which would be updated by having its DateAwarded field updated.&lt;br&gt;
&lt;br&gt;
If you have a People table, you could do the same thing to randomly pick a person if you&apos;d like.&lt;br&gt;
&lt;br&gt;
Then, append a new record to the PrizeWinners table with the PrizeID, the PeopleID and the DateAwarded fields.&lt;br&gt;
&lt;br&gt;
Finally, display the prize (and winner).&lt;br&gt;
&lt;br&gt;
Make sure that the computer is physically secured, and password protect the .mdb file (encrypt it on a thumbdrive that you keep in a safe place for even more security).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204032</guid>
		<pubDate>Wed, 16 Jan 2008 15:35:00 -0800</pubDate>
		<dc:creator>i love cheese</dc:creator>
	</item><item>
		<title>By: pompomtom</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204093</link>	
		<description>I have an excel solution, but I have nowhere to put it up (as I am trapped behind a firewall), so check your email. Should be self explanatory. Press the button, basically.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204093</guid>
		<pubDate>Wed, 16 Jan 2008 16:18:14 -0800</pubDate>
		<dc:creator>pompomtom</dc:creator>
	</item><item>
		<title>By: mphuie</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204095</link>	
		<description>Sounds overly complicated.&lt;br&gt;
&lt;br&gt;
Why not print the prizes on a piece of paper,  cut the paper into strips and put them into a box?  Write the names of the winners on the strips as you draw them out.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204095</guid>
		<pubDate>Wed, 16 Jan 2008 16:19:45 -0800</pubDate>
		<dc:creator>mphuie</dc:creator>
	</item><item>
		<title>By: TedW</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204234</link>	
		<description>Doing it the way mphuie suggests would be much more fun and exciting, not to mention immune from allegations of fraud (electronic voting, anyone?).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204234</guid>
		<pubDate>Wed, 16 Jan 2008 18:32:06 -0800</pubDate>
		<dc:creator>TedW</dc:creator>
	</item><item>
		<title>By: GregWithLime</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204388</link>	
		<description>I think you will also want some code that will randomly select a record from your prizes table. I wrote something quickly:&lt;br&gt;
&lt;br&gt;
Public Function GetWinningRecord(TableName As String, TestFieldName As String, IDFieldName)&lt;br&gt;
    Randomize&lt;br&gt;
    Dim MyDB As DAO.Database&lt;br&gt;
    Dim RSCount As DAO.Recordset&lt;br&gt;
    Dim RSTestRecord As DAO.Recordset&lt;br&gt;
    Dim RecID As Long&lt;br&gt;
    Dim I As Long&lt;br&gt;
    Set MyDB = CurrentDb&lt;br&gt;
    Set RSCount = MyDB.OpenRecordset(&quot;Select Count(&quot; &amp;amp; IDFieldName &amp;amp; &quot;) as TheCount &quot; _&lt;br&gt;
        &amp;amp; &quot;From &quot; &amp;amp; TableName &amp;amp; &quot; where &quot; &amp;amp; TestFieldName &amp;amp; &quot; = 0&quot;, dbOpenSnapshot)&lt;br&gt;
    RecID = Int((RSCount(&quot;thecount&quot;)) * Rnd + 1)&lt;br&gt;
    Set RSTestRecord = MyDB.OpenRecordset(&quot;Select &quot; &amp;amp; IDFieldName &amp;amp; &quot; &quot; _&lt;br&gt;
        &amp;amp; &quot;From &quot; &amp;amp; TableName &amp;amp; &quot; where &quot; &amp;amp; TestFieldName &amp;amp; &quot; = 0&quot;, dbOpenSnapshot)&lt;br&gt;
    For I = 1 To RecID - 1&lt;br&gt;
        RSTestRecord.MoveNext&lt;br&gt;
    Next&lt;br&gt;
    MyDB.Execute &quot;update &quot; &amp;amp; TableName &amp;amp; &quot; set &quot; &amp;amp; TestFieldName &amp;amp; &quot; = 1 &quot; _&lt;br&gt;
        &amp;amp; &quot;where &quot; &amp;amp; IDFieldName &amp;amp; &quot; = &quot; &amp;amp; RSTestRecord(IDFieldName)&lt;br&gt;
    &lt;br&gt;
    GetWinningRecord = RSTestRecord(IDFieldName)&lt;br&gt;
    &lt;br&gt;
End Function&lt;br&gt;
&lt;br&gt;
Passed into the function is the name of the table that contains the record record to choose, the name of the field that is the test field to determine whether the record has been selected already and the ID field for the record.&lt;br&gt;
&lt;br&gt;
The procedure marks the record as selected when it is called and returns the ID of the winning record. Your prize table would need some numeric primary key and a numeric field that stores whether the record has been called already. A sample table could contain these fields:&lt;br&gt;
&lt;br&gt;
Table Name: Prizes&lt;br&gt;
Fields:&lt;br&gt;
PrizeID AutoNumber&lt;br&gt;
PrizeName Text&lt;br&gt;
PrizeDesc Memo&lt;br&gt;
BeenSelected Long&lt;br&gt;
&lt;br&gt;
A sample call to the procedure would be:&lt;br&gt;
    MsgBox GetWinningRecord(&quot;Prizes&quot;, &quot;BeenSelected&quot;, &quot;PrizeID&quot;)&lt;br&gt;
&lt;br&gt;
The procedure would fail if it was called after all prizes has been selecte.&lt;br&gt;
&lt;br&gt;
Hope this helps!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204388</guid>
		<pubDate>Wed, 16 Jan 2008 21:33:10 -0800</pubDate>
		<dc:creator>GregWithLime</dc:creator>
	</item><item>
		<title>By: GregWithLime</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204389</link>	
		<description>Forgot to add that you need to reference DAO in your module.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204389</guid>
		<pubDate>Wed, 16 Jan 2008 21:34:08 -0800</pubDate>
		<dc:creator>GregWithLime</dc:creator>
	</item><item>
		<title>By: kc0dxh</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1204602</link>	
		<description>The slips-of-paper-in-the-hat method has gotten old and they are asking for something more flashy.  Not to mention that it&apos;s a lot of work.&lt;br&gt;
&lt;br&gt;
Tom, I got your email and, while that&apos;s not Access, it does make it easy for others to manage it.  It may end up being the core of what we use.  Thanks!&lt;br&gt;
&lt;br&gt;
GregWithLime, that seems slick, but I don&apos;t know where to put it.  I wish I understood these things better.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1204602</guid>
		<pubDate>Thu, 17 Jan 2008 07:25:29 -0800</pubDate>
		<dc:creator>kc0dxh</dc:creator>
	</item><item>
		<title>By: GregWithLime</title>
		<link>http://ask.metafilter.com/81186/Help-me-create-a-database-to-give-money-away#1205065</link>	
		<description>The code would go into a module. Click on the Modules button/tab and add a new one. Then you can paste my code into a module. While in the module, you need to reference the Microsoft DAO library. I don&apos;t have Access on the machine I am at right now but I believe references is located under Tools\References. &lt;br&gt;
&lt;br&gt;
Then, add a button to a form. Right click on the button and choose add code/procedure or whatever it says like that. Then you can place the call to the procedure there.&lt;br&gt;
&lt;br&gt;
Hope that helps...</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81186-1205065</guid>
		<pubDate>Thu, 17 Jan 2008 15:01:32 -0800</pubDate>
		<dc:creator>GregWithLime</dc:creator>
	</item>
	</channel>
</rss>
