I have a function that produces some temporary queries. I create the queries instead of just executing from VB because I need one temp query to depend on another temp query. All the queries are named "rqt_tmp_something" and once I'm done with them I run this handy procedure to find and delete them.
This one query called "rqt_tmp_pop_grp_struc_distinct" doesn't delete.
I have noticed while watching my local variables that the action queries and select distinct don't show up in tables, view or procedures (I am using ADO).
Where are they!?!
Here is my not so handy dandy code.
Expand|Select|Wrap|Line Numbers
- Function delete_tmp_rqts() As Boolean
- '***************
- 'BUT: supprimer les rqts avec "tmp" dans leur nom
- 'INPUT: s/o
- 'OUTPUT: 0 if succès, -1 si échec
- 'MAJ: EJ, 21 mai 2012
- '***************
- On Error GoTo Err_delete_tmp_rqts:
- Dim cat As ADOX.Catalog
- Dim cmd As ADOX.View
- Dim cnn As ADODB.Connection
- Dim p_cmd As ADOX.Procedure
- Dim tbl As ADOX.Table
- 'initialise catalog
- Set cnn = CurrentProject.Connection
- Set cat = New ADOX.Catalog
- Set cat.ActiveConnection = cnn
- 'effacer les requetes select
- For Each cmd In cat.Views
- If InStr(cmd.Name, "rqt_tmp") Then cat.Views.Delete cmd.Name
- Next cmd
- 'effacer les requetes d'action
- For Each tbl In cat.Tables
- If InStr(tbl.Name, "rqt_tmp") Then cat.Tables.Delete tbl.Name
- Next tbl
- For Each p_cmd In cat.Procedures
- If InStr(p_cmd.Name, "rqt_tmp") Then cat.Views.Delete cmd.Name
- Next p_cmd
- delete_tmp_rqts = True
- Exit_delete_tmp_rqts:
- Set cnn = Nothing
- Set cat = Nothing
- Exit Function
- Err_delete_tmp_rqts:
- delete_tmp_rqts = False
- Resume Exit_delete_tmp_rqts
- End Function