A
auujxa2 via AccessMonster.com
Here is code I have that deletes all queries, forms, and reports. The last
part I want to delete all modules but one. Any ideas? Case 4 is modules,
and the last line of the code is where I think the code I'm asking for should
go. Just don't know how to word it.
Thank YOu in advance
Dim db As Database 'Database to import
Dim strTDef As String 'Name of table or query to import
Dim qd As QueryDef 'Querydefs in db
Dim doc As Document 'Documents in db
Dim strCntName As String 'Document container name
Dim X As Integer 'For looping
Dim cntContainer As Container 'Containers in db
Dim strDocName As String 'Name of document
Dim intConst As Integer
Dim cdb As Database 'Current Database
Dim rel As Relation 'Relation to copy
Dim nrel As Relation 'Relation to create
Dim strRName As String 'Copied relation's name
Dim strTName As String 'Relation Table name
Dim strFTName As String 'Relation Foreign Table name
Dim varAtt As Variant 'Attributes of relation
Dim fld As Field 'Field(s) in relation to copy
Dim strFName As String 'Name of field to append
Dim strFFName As String 'Foreign name of field to append
'Open database which contains objects to import.
Set db = DBEngine.Workspaces(0).OpenDatabase(strPath, True)
'Delete all queries.
For Each qd In db.QueryDefs
strTDef = qd.Name
DoCmd.DeleteObject acQuery, strTDef
Next
'Loop through containers and delete all documents.
For X = 1 To 4
Select Case X
Case 1
strCntName = "Forms"
intConst = acForm
Case 2
strCntName = "Reports"
intConst = acReport
Case 3
strCntName = "Scripts"
intConst = acMacro
Case 4
strCntName = "Modules"
intConst = acModule
End Select
Set cntContainer = db.Containers(strCntName)
For Each doc In cntContainer.Documents
strDocName = doc.Name
DoCmd.DeleteObject acForm, strDocName
DoCmd.DeleteObject acMacro, strDocName
DoCmd.DeleteObject acReport, strDocName
part I want to delete all modules but one. Any ideas? Case 4 is modules,
and the last line of the code is where I think the code I'm asking for should
go. Just don't know how to word it.
Thank YOu in advance
Dim db As Database 'Database to import
Dim strTDef As String 'Name of table or query to import
Dim qd As QueryDef 'Querydefs in db
Dim doc As Document 'Documents in db
Dim strCntName As String 'Document container name
Dim X As Integer 'For looping
Dim cntContainer As Container 'Containers in db
Dim strDocName As String 'Name of document
Dim intConst As Integer
Dim cdb As Database 'Current Database
Dim rel As Relation 'Relation to copy
Dim nrel As Relation 'Relation to create
Dim strRName As String 'Copied relation's name
Dim strTName As String 'Relation Table name
Dim strFTName As String 'Relation Foreign Table name
Dim varAtt As Variant 'Attributes of relation
Dim fld As Field 'Field(s) in relation to copy
Dim strFName As String 'Name of field to append
Dim strFFName As String 'Foreign name of field to append
'Open database which contains objects to import.
Set db = DBEngine.Workspaces(0).OpenDatabase(strPath, True)
'Delete all queries.
For Each qd In db.QueryDefs
strTDef = qd.Name
DoCmd.DeleteObject acQuery, strTDef
Next
'Loop through containers and delete all documents.
For X = 1 To 4
Select Case X
Case 1
strCntName = "Forms"
intConst = acForm
Case 2
strCntName = "Reports"
intConst = acReport
Case 3
strCntName = "Scripts"
intConst = acMacro
Case 4
strCntName = "Modules"
intConst = acModule
End Select
Set cntContainer = db.Containers(strCntName)
For Each doc In cntContainer.Documents
strDocName = doc.Name
DoCmd.DeleteObject acForm, strDocName
DoCmd.DeleteObject acMacro, strDocName
DoCmd.DeleteObject acReport, strDocName