I want to be able to create some tables in code. I have queries defined to make the tables. Rather than specifying each query to run, I would like to be able to create a loop to execute the queries with names that start "qryMAKE". In this way, if more tables are added later on, I do not have to 'hard code' the names into the vb code. My question is - I'd like to use Execute but this doesn't seem to work as below and I can't see why not.
Dim db As Database, qdf As QueryDef
Set db = CurrentDb
For Each qdf In db.QueryDefs
If Left(qdf.Name,7) = "qryMAKE" Then
db.Execute qdf.Name
Else
Exit Sub
End If
Next
db.close
Dim db As Database, qdf As QueryDef
Set db = CurrentDb
For Each qdf In db.QueryDefs
If Left(qdf.Name,7) = "qryMAKE" Then
db.Execute qdf.Name
Else
Exit Sub
End If
Next
db.close