S
SysAccountant
I have created a series of Views(virtual tables) in MS Acces via the ADOX
library.However when I try and delete it via the delete method of thee Views
collection ,an error code pops up stating "the requested object isn't part of
the collection".
Can anyone,please, help me out of this situation?
Code sample:
Sub Main()
On Error GoTo DeleteViewError
Dim cat As New ADOX.Catalog
' Open the catalog
cat.ActiveConnection = CurrentProject.Connection
'Delete the View
cat.Views.Delete "dmRd_CardRefExtraction_Global2"
'Clean up
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Exit Sub
DeleteViewError:
Set cat = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
' EndDeleteViewVB
===============================================
Code used to create the object:
Function CreateView()
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim cat As New ADOX.Catalog
Dim sql_GLobalMerger_ExtractionAnalysis As String
Set conn = CurrentProject.Connection
cat.ActiveConnection = conn
sql_GLobalMerger_ExtractionAnalysis = "Select * from PseudoTable;"
cmd.CommandText = sql_GLobalMerger_ExtractionAnalysis
cat.Views.Append "dmRd_CardRefExtraction_Global2", cmd
sql_GLobalMerger_ExtractionAnalysis_MakeTable = "SELECT * INTO
[dmTbl_rdCardRefExtraction_Global] FROM dmRd_CardRefExtraction_Global2; "
DoCmd.SetWarnings (False)
DoCmd.RunSQL (sql_GLobalMerger_ExtractionAnalysis_MakeTable)
DoCmd.SetWarnings (True)
End Function
library.However when I try and delete it via the delete method of thee Views
collection ,an error code pops up stating "the requested object isn't part of
the collection".
Can anyone,please, help me out of this situation?
Code sample:
Sub Main()
On Error GoTo DeleteViewError
Dim cat As New ADOX.Catalog
' Open the catalog
cat.ActiveConnection = CurrentProject.Connection
'Delete the View
cat.Views.Delete "dmRd_CardRefExtraction_Global2"
'Clean up
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Exit Sub
DeleteViewError:
Set cat = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
' EndDeleteViewVB
===============================================
Code used to create the object:
Function CreateView()
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim cat As New ADOX.Catalog
Dim sql_GLobalMerger_ExtractionAnalysis As String
Set conn = CurrentProject.Connection
cat.ActiveConnection = conn
sql_GLobalMerger_ExtractionAnalysis = "Select * from PseudoTable;"
cmd.CommandText = sql_GLobalMerger_ExtractionAnalysis
cat.Views.Append "dmRd_CardRefExtraction_Global2", cmd
sql_GLobalMerger_ExtractionAnalysis_MakeTable = "SELECT * INTO
[dmTbl_rdCardRefExtraction_Global] FROM dmRd_CardRefExtraction_Global2; "
DoCmd.SetWarnings (False)
DoCmd.RunSQL (sql_GLobalMerger_ExtractionAnalysis_MakeTable)
DoCmd.SetWarnings (True)
End Function