Option Compare Database
Private Sub Form_Load()
' https://support.microsoft.com/en-us/help/280372/how-to-fill-a-list-box-or-a-combo-box-with-database-object-names
' https://www.techrepublic.com/blog/microsoft-office/use-a-form-to-display-a-list-of-reports-and-queries-in-an-access-database/
'AccessObject Collection Contains information about
' -----------------------------------------------------------------------
'Database diagram AllDatabaseDiagrams Saved database diagrams
'Form AllForms Saved forms
'Function AllFunctions Saved functions
'Macro AllMacros Saved macros
'Module AllModules Saved modules
'Query AllQueries Saved queries
'Report AllReports Saved reports
'Stored procedure AllStoredProcedures Saved stored procedures
'Table AllTables Saved tables
'View AllViews Saved views
' -----------------------------------------------------------------------
Dim accObject As Access.AccessObject
'Fill with Tables
'For Each accObject In CurrentData.AllFunctions
' Me.ListObjects.AddItem "Function;" & accObject.Name
'Next
'For Each accObject In CurrentData.AllMacros
' Me.ListObjects.AddItem "Macro;" & accObject.Name
'Next
For Each accObject In CurrentData.AllTables
Me.ListObjects.AddItem "TABLE;" & accObject.Name
Next
'If currently opened file is an Access database (mdb), then fill
'with queries.
'Otherwise, if it is an Access project (adp), fill with views,
'stored procedures, database diagrams, and functions.
If CurrentProject.ProjectType = acMDB Then
For Each accObject In CurrentData.AllQueries
Me.ListObjects.AddItem "QUERY;" & accObject.Name
Next
Else
For Each accObject In CurrentData.AllViews
Me.ListObjects.AddItem "VIEW;" & accObject.Name
Next
For Each accObject In CurrentData.AllStoredProcedures
Me.ListObjects.AddItem "PROCEDURE;" & accObject.Name
Next
For Each accObject In CurrentData.AllDatabaseDiagrams
Me.ListObjects.AddItem "DIAGRAM;" & accObject.Name
Next
For Each accObject In CurrentData.AllFunctions
Me.ListObjects.AddItem "FUNCTION;" & accObject.Name
Next
For Each accObject In CurrentData.AllMacros
Me.ListObjects.AddItem "Macro;" & accObject.Name
Next
End If
'Fill list with forms.
For Each accObject In CurrentProject.AllForms
Me.ListObjects.AddItem "FORM;" & accObject.Name
Next
' 'Fill list with Queriess.
' 'For Each accObject In CurrentProject.AllQueries
' ' ' Me.ListObjects.AddItem "QUERY;" & accObject.Name
' ' Next
'Fill list with reports.
For Each accObject In CurrentProject.AllReports
Me.ListObjects.AddItem "REPORT;" & accObject.Name
Next
'Fill list with data access pages.
For Each accObject In CurrentProject.AllDataAccessPages
Me.ListObjects.AddItem "PAGE;" & accObject.Name
Next
'Fill list with macros.
For Each accObject In CurrentProject.AllMacros
Me.ListObjects.AddItem "MACRO;" & accObject.Name
Next
'Fill list with modules.
For Each accObject In CurrentProject.AllModules
Me.ListObjects.AddItem "MODULE;" & accObject.Name
Next
End Sub
Private Sub ListObjects_DblClick(Cancel As Integer)
' DoCmd.OpenForm , accObject.Name, acNormal
' Dim rptReport As String
' rptReport = Me.MyListBox.Column(2)
' DoCmd.OpenReport rptReport, acPreview
' DoCmd.Close acForm, "ReportForm"
Dim DocName As String
Dim LinkCriteria As String
Dim accObject As Access.AccessObject
' DoCmd.Maximize
If Me.ListObjects.Column(0) = "Form" Then
DocName = Me.ListObjects.Column(1)
DoCmd.OpenForm DocName, , , LinkCriteria
ElseIf Me.ListObjects.Column(0) = "Report" Then
DocName = Me.ListObjects.Column(1)
DoCmd.OpenReport DocName, acViewPreview, , LinkCriteria
ElseIf Me.ListObjects.Column(0) = "Table" Then
DocName = Me.ListObjects.Column(1)
DoCmd.OpenTable DocName, acViewNormal
ElseIf Me.ListObjects.Column(0) = "Query" Then
DocName = Me.ListObjects.Column(1)
'DoCmd.OpenQuery DocName, acViewPreview, , LinkCriteria
'DoCmd.OpenQuery "Sales Totals Query", , acReadOnly
DoCmd.OpenQuery DocName, acViewNormal
ElseIf Me.ListObjects.Column(0) = "Macro" Then
DocName = Me.ListObjects.Column(1)
'DoCmd.OpenTable DocName, acViewNormal
DoCmd.RunMacro DocName
ElseIf Me.ListObjects.Column(0) = "Module" Then
DocName = Me.ListObjects.Column(1)
'DoCmd.OpenTable DocName, acViewNormal
Else
End If
'For Each accObject In CurrentProject.AllReports
' 'Me.listObjects.AddItem "REPORT;" & accObject.Name
' DoCmd.OpenReport DocName, acViewPreview, , LinkCriteria
' Next
'If Me.ListObjects.Column(0) = "Report" Then
' DocName = Me.ListObjects.Column(1)
' DoCmd.OpenReport "DocName", , , LinkCriteria
'DoCmd.OpenReport "DocName", acViewNormal
'DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"
'Else
End Sub
Kami bergerak dalam pembuatan Website Kantor, Toko Online, MS Access Database, Desain Grafis (Corel Draw & Photoshop), Gambar Teknik, Video Maker, Penjualan Laptop & PC dan lain-lainya
ini adalah contoh database yang dapat menyimpan ribuan Link ke Files atau Folder dan juga menyimpan Alamat Website