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: JetDatabaseSecure32 in Category Access/Jet Databases : Database from Total Visual SourceBook

Modifying Access database settings under workgroup security using JRO and 32 bit versions of VBA and VB6.

This allows Microsoft Access to compact a database using different workgroup security than the one used to open Access. Note that this code is not supported in the 64-bit version of Access 2010 or 2013 due to the use of the 32 bit library MSJRO.DLL. JRO has been deprecated after MDAC 2.7. JRO is not available on the 64-bit Windows operating system, and is not supported in the Microsoft Access 2007-2013 file format (*.accdb).

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the modJetDatabaseSecure32 module
CompactDatabaseBasicSecure Procedure Compact a secure database with no password
DatabasePasswordChangeSecure Procedure Compact the database into a new database with the new password
DatabasePasswordRemoveSecure Procedure Compact the database into a new database without a password
DatabaseEncryptSecure Procedure Compact the database into a new database with encryption
DatabaseDecryptSecure Procedure Compact the database into a new database without encryption
CompactDatabaseGeneralSecure Procedure Compact the specified database. Note that Access cannot compact the current database from VBA code. Set the database's Compact on Close option to do that. Note that this code is not supported in the 64-bit version of Access 2010 or 2013 due to the use of the 32 bit library MSJRO.DLL. JRO has been deprecated after MDAC 2.7. JRO is not available on the 64-bit Windows operating system, and is not supported in the Microsoft Access 2007-2013 file format (*.accdb).

Example Code for Using Module: JetDatabaseSecure32

' Example of modJetDatabaseSecure32
' Note: Workgroup security only applies to MDB databases and not ACCDB or ADP formats
'       This code is not supported in the 64-bit version of Access 2010 or 2013 due to the use of the 32 bit library MSJRO.DLL.
'
' To use this example, create a new module and paste this code into it.
' Then run the procedure by putting the cursor in the procedure and pressing:
'    F5 to run it, or
'    F8 to step through it line-by-line (see the Debug menu for more options)

Private Sub Example_modJetDatabaseSecure32()
  ' Comments: Examples of using the modJetDatabaseSecure32 module to modify Access database settings under workgroup security, for VB6 and 32 bit versions of VBA.

  Const cstrDBName As String = "C:\Total Visual SourceBook 2013\Samples\Sample_Secure.mdb"
  Const cstrWorkgroup As String = "C:\Total Visual SourceBook 2013\Samples\Sample_Secure.mdw"
  Const cstrUserID As String = "Testuser"
  Const cstrPassword As String = "password"

  Dim strError As String
  Dim strPassword As String

  ' Compact database
  strError = CompactDatabaseBasicSecure(cstrDBName, cstrWorkgroup, cstrUserID, cstrPassword)
  If strError = "" Then
    MsgBox "Database successfully compacted", vbInformation
  Else
    MsgBox "Database could not be compacted: " & strError, vbInformation
  End If

  ' Encrypt DB

  If MsgBox("Are you sure you want to encrypt this database: " & cstrDBName & "?", vbYesNo + vbQuestion) = vbYes Then
    strError = DatabaseEncryptSecure(cstrDBName, cstrWorkgroup, cstrUserID, cstrPassword, "")
    If strError = "" Then
      MsgBox "Database successfully encrypted", vbInformation
    Else
      MsgBox "Database could not be encrypted: " & strError, vbInformation
    End If
  End If

  ' Decrypt DB

  strError = DatabaseDecryptSecure(cstrDBName, cstrWorkgroup, cstrUserID, cstrPassword, "")
  If strError = "" Then
    MsgBox "Database successfully decrypted", vbInformation
  Else
    MsgBox "Database could not be decrypted: " & strError, vbInformation
  End If

  ' Add Password

  strPassword = InputBox("Enter database password to add:")

  If MsgBox("Are you sure you want to add the database password '" & strPassword & "' to " & cstrDBName & "?", vbYesNo + vbQuestion) Then
    strError = DatabasePasswordChangeSecure(cstrDBName, cstrWorkgroup, cstrUserID, cstrPassword, "", strPassword)
    If strError = "" Then
      MsgBox "Password successfully added", vbInformation
    Else
      MsgBox "Password unsuccessfully added: " & strError, vbInformation
    End If
  End If

  strError = DatabasePasswordRemoveSecure(cstrDBName, cstrWorkgroup, cstrUserID, cstrPassword, strPassword)
  If strError = "" Then
    MsgBox "Password successfully removed", vbInformation
  Else
    MsgBox "Password unsuccessfully removed: " & strError, vbInformation
  End If

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