To answer your question more directly, yes the code needs to be housed in one way or another, either as an argument in the DoCmd.RunSQL part or in a string field. However, you don't have to reassign variables as you have above. If I have a dinky bit of one line SQL code, i do as above...