Code to delete querydef's

  • Thread starter Thread starter JimP
  • Start date Start date
J

JimP

I have code that loops through the querydefs collection to delete each
querydef. The problem seems to be that it deletes every other one, as if a
pointer gets thrown off with each deletion. Suggestions?
 
If you are using an increasing index number to loop, reverse it.

For i = tabledefs.count to 1 step -1

not

For i = 1 to tabledefs.count

This would be true when using an index number to delete from any collection
object.

HTH,
 
The code I've been using is,

Dim qdf as Querydef
qdfs = Currentdb.Querydefs
For each qdf in qdfs
qdfs.Delete qdf.Name
Next qdf

I'll try the negative loop incrementer.
 
Back
Top