(start and finish are indicated by <<<<<<<<<<<< and >>>>>>>>>>>)
This action has to clean the specified database so, that delete all but
specified forms;
it is called from elsewhere by
call DelSaveFormsNew( dbfile, "f01",f02",...
In 97 this works as expected.
In 2000 deleting is not performed, when commeenting "on error" line in
deleteObject function and error 2501 is coming.
What could be reason for this.
<<<<<<<<<<<<<<<<<<<<<<<<<<<
Sub DelSaveFormsNew(DbFile As String, ParamArray FormsSaved() As Variant)
Dim intI As Integer
Dim dbs As Database, ctr As Container, doc As Document
' Returns reference to current database.
Set dbs = OpenDatabase(DbFile)
' Returns referenct to Forms container.
Set ctr = dbs.Containers!Forms
' Enumerates through Documents collection of Forms container.
For Each doc In ctr.Documents
' check if it is in array
For intI = LBound(FormsSaved()) To UBound(FormsSaved())
If doc.Name = FormsSaved(intI) Then
intI = 1000
End If
Next intI
If intI < 1000 Then
Debug.Print "to be deleted "; doc.Name
Debug.Print "DeleteObject(dbfile,acForm, doc.Name) = ";
DeleteObject(DbFile, acForm, doc.Name)
Else
Debug.Print "to be saved "; doc.Name; " intI=", intI
End If
Next doc
Set dbs = Nothing
End Sub
>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<
Public Function DeleteObject(Filename As String, _
objType As Integer, _
objName As String) As Boolean
On Error GoTo DeleteObject_Err
Dim accObj As New Access.Application
accObj.OpenCurrentDatabase Filename
accObj.DoCmd.DeleteObject objType, objName
accObj.CloseCurrentDatabase
Set accObj = Nothing
DeleteObject = True
DeleteObject_End:
Exit Function
DeleteObject_Err:
Resume DeleteObject_End
End Function
>>>>>>>>>>>>>>>>>>>>>>>>>>>
--
V.Moltchanov