Why delete and recreate a querydef object when you can just change the .SQL property?
Posted
by
dblE
on Stack Overflow
See other posts from Stack Overflow
or by dblE
Published on 2014-08-22T16:55:40Z
Indexed on
2014/08/22
22:21 UTC
Read the original article
Hit count: 95
Do you remember the venerable old Microsoft Query by Form (QBF) VBA example from back in the day link that recommended that you delete an existing query and then recreate it dynamically?:
On Error Resume Next
db.QueryDefs.Delete ("qryResults")
On Error GoTo 0
Set qdf = db.CreateQueryDef("qryResults", "SELECT p.*...
Why not just change the SQL property of the querydef object?
qdf.SQL = "SELECT p.*...
I am wondering if anyone knows why the MS engineers wrote an example that suggests that you delete and then recreate a query instead of simply changing the SQL property? I would guess that the act of deleting and recreating objects over time could contribute to corruption and bloating in your front end, not to mention changing the SQL property is so much simpler. Does anyone have more insight into this?
© Stack Overflow or respective owner