Well you would most likely put that code into a public module, then call the code from either a macro or button click, or if you're testing it just running it from the code window itself.
That being said it may be worthwhile for you to check out the Code Repository on this site, seeing how a database with code is setup is worth a 1000 words.