Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"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

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Module: ManagingObjects in Category Microsoft Access : Objects from Total Visual SourceBook

Delete, duplicate, rename, and export Microsoft Access objects in Jet (ACCDB/MDB) and ADP databases in Access VBA.

Procedure List

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: 1. Has to be at least one character in length. 2. Has to be fewer than 64 characters in length. 3. Cannot start with a space or equals sign. 4. Cannot contain any of the following characters: ! . [ ] `

Example Code for Using Module: ManagingObjects

' 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

Microsoft Access Module LibraryOverview of Total Visual SourceBook

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.

Additional Resources