Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing/deleting passthru queries

Status
Not open for further replies.

abenitez77

IS-IT--Management
Oct 18, 2007
147
0
0
US
I have this code that loops thru the querydef's and deletes the passthru queries, but it always leaves out a few. When I tried to trap an error, it does not give me the error description. It also does not finishing looping thru all the querydefs. Why does it not catch all of them?



Function ClearPassThruQueries()
'On Error Resume Next
On Error GoTo ClearODBC_Err

Dim daoDB As DAO.Database
Dim daoQDF As DAO.QueryDef



Set daoDB = CurrentDb()
cnt = daoDB.QueryDefs.Count


For Each daoQDF In daoDB.QueryDefs


'daoQDF.Type = 0 Are Local queries, 112 Are Passthru queries
If daoQDF.Name = "ToolSettings" Or daoQDF.Name = "DataList" Or daoQDF.Name = "Projects" Or daoQDF.Type = 0 Then
'Don't Delete these connections/queries.
Else
'Name matched the naming spec, so zap it!
daoDB.QueryDefs.Delete (daoQDF.Name)
'Refresh the list of remaining QueryDef objects
daoDB.QueryDefs.Refresh
End If


Next


ClearODBC_Err:

ClearPassThruQueries = False
MsgBox "ClearODBC encountered an unexpected error: " & Err.Description



End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top