You don't even need a (saved) query at all in this case... you can justReference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10951Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10951
construct your SQL statement in code and execute it without saving it at
As a simple example, suppose there is a table called tblSpecies, and you
want to filter on field SpeciesType (animal, flower etc) and create a
new table called tblSpeciesOfType; filter selection is made by means of
a combo box (cboSpeciesType) on a form, and the make-table query is run
by clicking a command button on the same form. The code behind the
command button would look something like:
Dim strSQL As String
If IsNull(Me.cboSpeciesType) Then
MsgBox "No species type selected.", vbExclamation, _
"Error Creating Table"
strSQL = "SELECT * INTO tblSpeciesOfType FROM tblSpecies " & _
"WHERE SpeciesType = '" & Me.cboSpeciesType & "'"
CurrentDb.Execute strSQL, dbFailOnError
This will overwrite the table if it already exists.
That said, are you positive you need to create a new table? Why don't
you just filter on the existing one(s) by means of a Select query?
Duplication of data is not advisable for a number of reasons, having to
do with data integrity and maintenance, storage space etc. Elaborate if
you need further help.