![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Delete query def Hello, Using Access ’03… In my error handling, I have the following code: Exit Sub errHandler: On Error Resume Next dbs.QueryDefs.Delete (strQDF) msgbox err.description End Sub What I’m trying to do, is that if my sub fails for any reason; delete the query def(s) that may have been created before the error occurred. Seems simple enough, but for some strange reason I’m getting a run- time error in my error handling:’3265’ Item not found in this collection. I use On Error Resume Next before I delete any qdf, just in case it does not exist--and it's always worked. I don’t understand why it doesn’t work in error handling? Can someone clue me in? Thanks, alex |
#4
| |||
| |||
|
|
try a loop in your error handler Dim qdf as QueryDef .. Err: For Each qdf In dbs.Querydefs * If qdf.Name = strQDF Then * *dbs.QueryDefs.Delete (strQDF) * *Exit For * End if Next Exit Sub Rich *** Sent via Developersdexhttp://www.developersdex.com*** |
#5
| |||
| |||
|
|
If you haven't appended it to the querydefs collection, it's just a temporary, so you don't have to delete it. John alex used his keyboard to write : Delete query def Hello, Using Access ’03… In my error handling, I have the following code: Exit Sub errHandler: * * * * * *On Error Resume Next * * * * * *dbs.QueryDefs.Delete (strQDF) * *msgbox err.description End Sub What I’m trying to do, is that if my sub fails for any reason; delete the query def(s) that may have been created before the error occurred. Seems simple enough, but for some strange reason I’m getting a run- time error in my error handling:’3265’ Item not found in this collection. I use On Error Resume Next before I delete any qdf, just in case it does not exist--and it's always worked. *I don’t understand why it doesn’t work in error handling? Can someone clue me in? Thanks, alex- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
| Thanks Rich; that did work. I have two qdfs so I have to write two |
![]() |
| Thread Tools | |
| Display Modes | |
| |