Error 3265, "Item cannot be found in the collection corresponding to the requested name or ordinal"
code programatically opens a query using ADOX and changed the sql
debug says the error is on the line:
5. Set cmd = cat.Procedures( "qryLostCostCod es").Command
so I was thinking maybe it couldn't find the query to open, but then if you alter it create a new query instead you get the error "Query already exists" (and I can see it exists)
the SQL is:
and costcode and name defintely exist... I even had this running at one point!
Any Ideas?
code programatically opens a query using ADOX and changed the sql
Code:
Dim cat As New ADOX.Catalog Dim cmd As New ADODB.Command cat.ActiveConnection = CurrentProject.Connection Set cmd = cat.Procedures("qryLostCostCodes").Command 'opens existing query to edit cmd.CommandText = whr 'this should be your sql SELECT string Set cat.Procedures("qryLostCostCodes").Command = cmd 'save query cat.Views.Refresh Set cat = Nothing Set cmd = Nothing
5. Set cmd = cat.Procedures( "qryLostCostCod es").Command
so I was thinking maybe it couldn't find the query to open, but then if you alter it create a new query instead you get the error "Query already exists" (and I can see it exists)
the SQL is:
Code:
SELECT [costcode], [name] FROM Site WHERE costcode NOT IN ('B', 'A9000', 'I9000', 'I4000', 'I4300', 'I4200')
Any Ideas?
Comment