Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the modManagingObjects module. |
DeleteObject | Procedure | Delete an object (table, query etc.) using the DeleteObject action. If the object cannot be deleted, the function returns a value of False. If it returns True, the object no longer exists. |
DuplicateObject | Procedure | Duplicate (copy) an object (table, query, form, report, macro, module, diagram, view, stored procedure, etc.) in its own database. If an object with the new name already exists, it is overwritten. This function can fail if the target object exists and is being used. |
DuplicateTableStructure | Procedure | Duplicate (copy) a table's structure (no data) into a new table in the current database. |
ExportObject | Procedure | Export (copy) an object (table, query, form, report, macro, module, diagram, view, stored procedure, etc.) to another database. The other database needs to support the exported object type (e.g. tables with ACCDB data types can't go to an MDB). |
RenameObject | Procedure | Rename an object (table, query etc.). If an object with the new name already exists, it is overwritten. This function can fail if the target object exists and is being used. |
IsValidAccessName | Procedure | Determine if the supplied name is a valid name for an Access object. The following rules are used:
|
' Example of modManagingObjects ' ' To try this example, do the following: ' 1. Create a new form in your copy of Sample.mdb. ' 2. Create a command button 'cmdTest' ' 3. Paste this code into the form's module Private Sub Form_Open(Cancel As Integer) Me.cmdTest.Caption = "Test Access managing objects functions" End Sub Private Sub cmdTest_Click() Const cstrSampPath As String = "C:\Total Visual SourceBook 2013\Samples\sample.mdb" Dim fOK As Boolean Dim strMacroName As String ' Test if a name is valid strMacroName = "!!BadAccessName!!" If IsValidAccessName(strMacroName) Then Debug.Print strMacroName & " is a valid name." Else Debug.Print strMacroName & " is a NOT valid name." strMacroName = "FMSTest" If IsValidAccessName(strMacroName) Then Debug.Print strMacroName & " is a valid name." Else Debug.Print strMacroName & " is NOT a valid name." End If End If ' Example of DuplicateObject fOK = DuplicateObject(acMacro, "Quit", "Copy of Quit") Debug.Print "Copied macro 'Quit' to 'Copy of Quit'...: " & IIf(fOK, "Successful", "Failed") ' Example of RenameObject fOK = RenameObject(acMacro, "Copy of Quit", strMacroName) Debug.Print "Renamed 'Copy of Quit' to '" & strMacroName & "'...: " & IIf(fOK, "Successful", "Failed") ' Example of DeleteObject fOK = DeleteObject(acMacro, strMacroName) Debug.Print "Deleted macro '" & strMacroName & "'...: " & IIf(fOK, "Successful", "Failed") ' Example of DuplicateTableStructure fOK = DuplicateTableStructure("Customers", "Customers_Shell") Debug.Print "Copied table structure 'Customers' to 'Customers_Shell'...: " & IIf(fOK, "Successful", "Failed") ' Example of ExportObject fOK = ExportObject(acTable, "Customers_Shell", "Customers_Shell", cstrSampPath) Debug.Print "Exported 'Customers_Shell' to " & cstrSampPath & "...: " & IIf(fOK, "Successful", "Failed") ' Example of DeleteObject fOK = DeleteObject(acTable, "Customers_Shell") Debug.Print "Deleted table 'Customers_Shell'...: " & IIf(fOK, "Successful", "Failed") End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP