Hi all.
I'm writing almost all my queries in VBA and in this forum I've learned that to save memory it's best saving the queries and then execute them.
Often I'm using one query as a source for the next query (can't remember what it's called
) and all the queries containing parametres and I find this method usefull - let VBA controle the parametres and ACCESS controle the queries.
So I'm using the following structure:
dbs.QueryDefs.Refresh
For Each QueryNameMain In dbs.QueryDefs
If QueryNameMain.Name = "MyQuery" Then
dbs.QueryDefs.Delete QueryNameMain.Name
End If
Next QueryNameMain
strSQL = "SELECT ......."
Set QueryNameMain = dbs.CreateQueryDef("MyQuery", strSQL)DoCmd.OpenQuery QueryNameMain.Name
BUT it's annoys me that I have to delete the whole query, change the value of the parameter and save the query once again - also because I find this method a little unsecure.
Is there another way of "updating" the queries or only this way (delete and write) ??
Best regards
Søren
I'm writing almost all my queries in VBA and in this forum I've learned that to save memory it's best saving the queries and then execute them.
Often I'm using one query as a source for the next query (can't remember what it's called

So I'm using the following structure:
dbs.QueryDefs.Refresh
For Each QueryNameMain In dbs.QueryDefs
If QueryNameMain.Name = "MyQuery" Then
dbs.QueryDefs.Delete QueryNameMain.Name
End If
Next QueryNameMain
strSQL = "SELECT ......."
Set QueryNameMain = dbs.CreateQueryDef("MyQuery", strSQL)DoCmd.OpenQuery QueryNameMain.Name
BUT it's annoys me that I have to delete the whole query, change the value of the parameter and save the query once again - also because I find this method a little unsecure.
Is there another way of "updating" the queries or only this way (delete and write) ??
Best regards
Søren