Why delete and recreate a querydef object when you can just change the .SQL property?
- by dblE
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?