troubleshooting Question

Deleting Queries in Access 2003 using VBA

Avatar of ashercim
ashercim asked on
Microsoft Access
5 Comments1 Solution344 ViewsLast Modified:
I've got an Access 2003 application that I'm developing, and it works great except for 1 remaining bug.

I can't seem to delete a QueryDef from the collection.  The code for this follows:

           For Each qdf In db.QueryDefs
                        'MsgBox (qdf.Name)
                        If qdf.Name = "qryTemp2" Then db.QueryDefs.Delete "qryTemp2"
             Next qdf

This temporary query may or may not be created at some point depending on the options that the user has chosen.  What I'm not understanding is that when qdf.name="qryTemp2" I'm getting a runtime 3011 error saying that the Jet Database Engine could not find the object qryTemp2.

It doesn't show up in the database window, but no matter what I do, I can't seem to remove this name from the Querydefs collection.

By the way, i set qdf as:

Dim qdf As DAO.QueryDef

I haven't had any problems like this in any of the other applications I've been developing and I don't understand it.  Any help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
harfang

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 5 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004