Dynamic SQL... build an event on your "Submit" button.
It involves:
First, set a string variable strSQL equal to the correct SQL.
Then, CurrentDb.QueryDefs("QueryName").SQL = strSQL
If you can't get it, paste your SQL code and I can show you specifically.