Delete Table/Query

Z

zyus

Is there any way to delete table & query in just one shot. Sort of select all
table/query name and press delete.

Thanks
 
S

Stefan Hoffmann

hi,
Is there any way to delete table & query in just one shot. Sort of select all
table/query name and press delete.
What exactly do you mean? You can write your own VBA sub to do this.

mfG
--> stefan <--
 
Z

zyus

Hi,

I use access for reporting purpose. I've created a lot of query & reports. I
want to find a way to delete my queries from query windows by selection and
delete.
 
S

Stefan Hoffmann

hi,
I use access for reporting purpose. I've created a lot of query & reports. I
want to find a way to delete my queries from query windows by selection and
delete.
Copy it into a standard module and use it with extreme care:

Public Sub DeleteAllQueries()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim qds() As DAO.QueryDef

Dim Count As Long

Set db = CurrentDb
ReDim qds(db.QueryDefs.Count)

For Count = 0 To db.QueryDefs.Count - 1
Set qds(Count) = db.QueryDefs.Item(Count)
Next Count

For Count = 0 To db.QueryDefs.Count - 1
db.QueryDefs.Delete qds(Count).Name
Next Count
db.QueryDefs.Refresh

Set db = Nothing

End Sub


mfG
--> stefan <--
 
J

John W. Vinson

hi,

Copy it into a standard module and use it with extreme care:

Public Sub DeleteAllQueries()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim qds() As DAO.QueryDef

Dim Count As Long

Set db = CurrentDb
ReDim qds(db.QueryDefs.Count)

For Count = 0 To db.QueryDefs.Count - 1
Set qds(Count) = db.QueryDefs.Item(Count)
Next Count

For Count = 0 To db.QueryDefs.Count - 1
db.QueryDefs.Delete qds(Count).Name
Next Count
db.QueryDefs.Refresh

Set db = Nothing

End Sub

Zyus, do note that this will delete *EVERY QUERY* in your entire database -
not "by selection". Heed Stefan's warning to "use with extreme care" - it's a
tactical nuclear device, not a rifle!
 
S

Stefan Hoffmann

hi John,
Zyus, do note that this will delete *EVERY QUERY* in your entire database -
not "by selection". Heed Stefan's warning to "use with extreme care" - it's a
tactical nuclear device, not a rifle!
Cool ;)


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top