I found the answer elsewhere and I'm ashamed I overlooked the simple solution. As long as my query is already defined, I can modify as such:
Sub ReplaceQuery()
strSQL = "SELECT * FROM MYDATA;"
CurrentDb.QueryDefs("qryMyQuery").SQL = strSQL
DoCmd.OpenQuery "qryMyQuery", acViewNormal...
My ERP software is dictating that I use ADO connections. I have been able to convert all my code except when I need to modify a querydef. In DAO it was like this:
Sub ReplaceQuery()
Dim dbs As Database, qdf As QueryDef
Set dbs = CurrentDb
dbs.QueryDefs.Refresh
For Each qdf In dbs.QueryDefs
If...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.