The answer is, "No, it's not." Not when you could have done it all with VBA, that is! By accessing the object's Dependencies collection, we can find and export every object that your form or report requires to run.
The dependencies are saved in the databases system tables, not in the object definitions themselves, so they must be populated to their own object using [object].GetDependencies. From there, it's just a matter of iterating through all of the dependencies.
The following three code procedures accomplish exporting each dependency object to a purpose-created database. You can then send the package to another developer or copy it wholesale into another working database. Paste the code into a new module to use it.
The first procedure creates the export database and passes the top-level object to the packaging procedure. The DepColl array and DepI iterator are used to hold references to all of the converted objects in order to keep from converting the same objects due to multiple dependencies. In this procedure, we also make sure that "Track Name Autocorrect Info" is set to True (1), because this creates the system table that stores all object dependencies.
Expand|Select|Wrap|Line Numbers
- 'PackageObjects Module
- 'Example: PackageObject([Object Name],"Form" or "Report")
- '2014 Topher Ritchie
- 'This code is free for use in development and must
- 'retain this section.
- '=========================================================
- 'Module Declarations section
- '=========================================================
- Option Compare Database
- Option Explicit
- Public DepColl() As String
- Public DepI As Long
- Public Sub PackageObject(strObject As String, strType As String)
- Dim db As Object
- Application.SetOption "Track Name AutoCorrect Info", 1
- Access.DBEngine.CreateDatabase "F:\MyDatabases\dbExport_" & Format(Date, "yyyy-mm-dd") & ".accdb", DB_LANG_GENERAL
- Set db = Application.CurrentProject
- If strType = "Form" Then
- OutputItem strObject, -32768
- PackageDependencies db.AllForms.Item(strObject)
- ElseIf strType = "Report" Then
- OutputItem strObject, -32764
- PackageDependencies db.AllReports.Item(strObject)
- End If
- ReDim DepColl(0)
- DepI = 0
- End Sub
Expand|Select|Wrap|Line Numbers
- Public Sub PackageDependencies(objObject As Object)
- Dim DepObj As Object
- Dim DepObjColl As Object
- Dim i As Long
- On Error GoTo Err_Exit:
- Set DepObjColl = objObject.GetDependencyInfo
- For Each DepObj In DepObjColl.Dependencies
- For i = 1 To DepI
- If DepObj.name = DepColl(i) Then GoTo SkipObj
- Next i
- DepI = DepI + 1
- ReDim Preserve DepColl(DepI)
- DepColl(DepI) = DepObj.name
- OutputItem DepObj.name, DLookup("Type", "MSysObjects", "NAME = '" & DepObj.name & "'")
- PackageDependencies DepObj
- SkipObj:
- Next DepObj
- Err_Exit:
- End Sub
Expand|Select|Wrap|Line Numbers
- Public Sub OutputItem(strName As String, lngType As Long)
- Debug.Print strName, lngType
- If lngType = 1 Or lngType = 6 Then
- DoCmd.TransferDatabase acExport, "Microsoft Access", "F:\PRISM\PRISM Support Programs\Development\dbExport_" & Format(Date, "yyyy-mm-dd") & ".accdb", acTable, strName, strName
- ElseIf lngType = 5 Then
- DoCmd.TransferDatabase acExport, "Microsoft Access", "F:\PRISM\PRISM Support Programs\Development\dbExport_" & Format(Date, "yyyy-mm-dd") & ".accdb", acQuery, strName, strName
- ElseIf lngType = -32768 Then
- DoCmd.TransferDatabase acExport, "Microsoft Access", "F:\PRISM\PRISM Support Programs\Development\dbExport_" & Format(Date, "yyyy-mm-dd") & ".accdb", acForm, strName, strName
- ElseIf lngType = -32764 Then
- DoCmd.TransferDatabase acExport, "Microsoft Access", "F:\MyDatabases\dbExport_" & Format(Date, "yyyy-mm-dd") & ".accdb", acReport, strName, strName
- End If
- End Sub