How temporary are the SQL statements? If just in one session, you could store them in an array. If more than one session, stored in a table, for instance you could run into various problems.
One option would be to allow users to save commonly run queries, and let them select them from a list. If they need to set various parameters, you could prompt for them in various ways. Or if there are commonly used sets of parameters, something like szlamany's select would work.
But for a Forward/Back button, an array may be best. I suppose a collection would work, but might be overkill.