PeterBaileyUk
asked on
delete queries in access
I want to delete queries in my db that have any of the names but not the word "column", will this work?
if not how please
For Each Qry In Db.QueryDefs
Select Case Qry.Name
Case InStr(Qry.Name, "abi") <> 0 And InStr(Qry.Name, "column") > 0
DoCmd.DeleteObject acQuery, Qry.Name
Case InStr(Qry.Name, "cap") <> 0 And InStr(Qry.Name, "column") > 0
DoCmd.DeleteObject acQuery, Qry.Name
Case InStr(Qry.Name, "glass") <> 0 And InStr(Qry.Name, "column") > 0
DoCmd.DeleteObject acQuery, Qry.Name
Case InStr(Qry.Name, "kee") <> 0 And InStr(Qry.Name, "column") > 0
DoCmd.DeleteObject acQuery, Qry.Name
Case InStr(Qry.Name, "smmt") <> 0 And InStr(Qry.Name, "column") > 0
DoCmd.DeleteObject acQuery, Qry.Name
End Select
Next
if not how please
ASKER
the queries are like this which can be deleted
QryGlass3Series
Qry[clientname][model]
BUT
I must preserve queries like so "columnout" is keyword
QryABIColumnOut
the five client names are
abi
glass
kee
cap
smmt
QryGlass3Series
Qry[clientname][model]
BUT
I must preserve queries like so "columnout" is keyword
QryABIColumnOut
the five client names are
abi
glass
kee
cap
smmt
clear as mud!
What is "columnout" is keyword?
What is "columnout" is keyword?
ASKER
its a word in the queries I dont want to delete only five of them
QryAbiColumnOut
QryCapColumnOut
QryKeeColumnOut
QrySMMTColumnOut
QryGlassColumnOut
The rest I want to delete are of the form
Qry[clientname]xxx ie abi cap etc as above 5 client names butthe xxx part does not have columnout
QryAbiColumnOut
QryCapColumnOut
QryKeeColumnOut
QrySMMTColumnOut
QryGlassColumnOut
The rest I want to delete are of the form
Qry[clientname]xxx ie abi cap etc as above 5 client names butthe xxx part does not have columnout
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
because I found the solution myself
For Each Qry In Db.QueryDefs
if InStr(Qry.Name, "column") > 0 then
DoCmd.DeleteObject acQuery, Qry.Name
end if
next