Module: AccessWindow in Category Microsoft Access : Environment from Total Visual SourceBook

Show and disable the Microsoft Access window controls to prevent users from exiting beyond your application's control using Windows API calls for 32 and 64-bit VBA.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the modAccessWindow module.
AccessControlBoxesVisible Procedure Show or hides the control box for the Access window. The control box is in the upper right corner and contains the minimize, maximize and close boxes.
AccessCloseButtonEnabled Procedure Enables and disables the close button of the current application. Disabling it prevents users from accidentally closing Access from the Windows close button in the upper right corner and forces users to exit within your application. For more information, visit Disable the Microsoft Access Close Button to Prevent Users from accidentally closing your Application.
AccessWindowOpacity Procedure Set the Opacity/transparency of the Access window.
AccessWindowTransparent Procedure Make the Access window completely transparent.
AccessWindowSemiTransparent Procedure Make the Access window partially transparent.
AccessWindowOpaque Procedure Reset the Access window to be completely opaque.
' Example of the modAccessWindow class
'
' To try this example, do the following:
' 1. Create a new form
' 2. Add the following command buttons:
'       cmdControlBox
'       cmdCloseBtn
'       cmdOpacity
'       cmdOpaque
'       cmdSemiTransparent
'       cmdTransparent
' 3. Paste all the code from this example to the new form's module
' 4. Run the form.

#If VBA7 Then
  Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
#Else
  Private Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
#End If

Private Sub cmdCloseButton_Click()
  If cmdCloseButton.Caption = "Disable close button" Then
    AccessCloseButtonEnabled False
    cmdCloseButton.Caption = "Enable close button"
  Else
    AccessCloseButtonEnabled True
    cmdCloseButton.Caption = "Disable close button"
  End If
End Sub

Private Sub cmdControlBox_Click()
  If cmdControlBox.Caption = "Hide control box" Then
    AccessControlBoxesVisible False
    cmdControlBox.Caption = "Show control box"
  Else
    AccessControlBoxesVisible True
    cmdControlBox.Caption = "Hide control box"
  End If
End Sub

Private Sub cmdOpacity_Click()
  Select Case Me.cmdOpacity.Caption
    Case "Set window opacity: 75%"
      AccessWindowOpacity (255 * 0.75)
      Me.cmdOpacity.Caption = "Set window opacity: 50%"
    Case "Set window opacity: 50%"
      AccessWindowOpacity (255 * 0.5)
      Me.cmdOpacity.Caption = "Set window opacity: 25%"
    Case "Set window opacity: 25%"
      AccessWindowOpacity (255 * 0.25)
      Me.cmdOpacity.Caption = "Set window opacity: 75%"
    Case Else
      AccessWindowOpacity (255)
      Me.cmdOpacity.Caption = "Set window opacity: 75%"
  End Select
End Sub

Private Sub cmdOpaque_Click()
  AccessWindowOpaque
  Me.cmdOpacity.Caption = "Set window opacity: 75%"
End Sub

Private Sub cmdSemiTransparent_Click()
  AccessWindowSemiTransparent
  Me.cmdOpacity.Caption = "Set window opacity: 25%"
End Sub

Private Sub cmdTransparent_Click()
  MsgBox "Form will be transparent for 3 seconds."
  AccessWindowTransparent
  Sleep 3000
  AccessWindowOpaque
  Me.cmdOpacity.Caption = "Set window opacity: 75%"
End Sub

Private Sub Form_Load()

  ' Set defaults
  AccessCloseButtonEnabled True
  AccessControlBoxesVisible True
  AccessWindowOpaque

  ' Setup controls
  With Me.cmdCloseButton
    .Caption = "Disable close button"
    .Top = 100
    .Left = 100
    .Width = 3500
  End With
  With Me.cmdControlBox
    .Caption = "Hide control box"
    .Top = 500
    .Left = 100
    .Width = 3500
  End With
  With Me.cmdOpacity
    .Caption = "Set window opacity: 75%"
    .Top = 900
    .Left = 100
    .Width = 3500
  End With
  With Me.cmdOpaque
    .Caption = "Reset opacity"
    .Top = 1300
    .Left = 100
    .Width = 3500
  End With
  With Me.cmdSemiTransparent
    .Caption = "Make window semi-transparent"
    .Top = 1700
    .Left = 100
    .Width = 3500
  End With
  With Me.cmdTransparent
    .Caption = "Make window transparent"
    .Top = 2100
    .Left = 100
    .Width = 3500
  End With

End Sub

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.

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!

Additional Resources

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 and VB6

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


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"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

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS