IAMCONFUSED
Programmer
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 qdf.Name = "qryMyQuery" Then dbs.QueryDefs.Delete qdf.Name
Next qdf
strSQL = "SELECT * FROM MYDATA;"
Set qdf = dbs.CreateQueryDef("qryMyQuery", strSQL)
DoCmd.OpenQuery qdf.Name, acViewNormal, acReadOnly
Set dbs = Nothing
End Sub
I have simplified my sql statment for demo purposes only, but I need to be able to modify a current query def in access 2000 using vba.
I have looked everywhere for weeks with no solution. If anyone can point me in the right direction, I would very much appreciate it.
Sub ReplaceQuery()
Dim dbs As Database, qdf As QueryDef
Set dbs = CurrentDb
dbs.QueryDefs.Refresh
For Each qdf In dbs.QueryDefs
If qdf.Name = "qryMyQuery" Then dbs.QueryDefs.Delete qdf.Name
Next qdf
strSQL = "SELECT * FROM MYDATA;"
Set qdf = dbs.CreateQueryDef("qryMyQuery", strSQL)
DoCmd.OpenQuery qdf.Name, acViewNormal, acReadOnly
Set dbs = Nothing
End Sub
I have simplified my sql statment for demo purposes only, but I need to be able to modify a current query def in access 2000 using vba.
I have looked everywhere for weeks with no solution. If anyone can point me in the right direction, I would very much appreciate it.