Microsoft AccessThis function allows you to bring a specific form to the top so that you can be certain that the user can see it.

To use:

  1. Save this code into a new module called FormHelper.
  2. Call FormHelper.BringToTop with the Form object you wish to bring to the top.

The code is fully commented and contains more details on implementation and what the functions can and can’t do.

Option Compare Database
Option Explicit

Private Const Namespace$ = "FormHelper"


''' 
''' Used by BringToTop
''' 
Private Declare Function apiBringWindowToTop Lib "user32" Alias "BringWindowToTop" ( _
                         ByVal hwnd As Long) _
                         As Long
                         
                         
                         
''' 
''' Brings form to top and activates it
''' 
''' 
''' Uses following Declare:
''' <code>Private Declare Function apiBringWindowToTop Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long) As Long</code>
''' 
Public Sub BringToTop( _
           frm As Access.Form)
  apiBringWindowToTop frm.hwnd
  End Sub

You can also download FormHelper.bas. This is always the latest complete version of this module and contains more functions than detailed here. The functions are fully commented.

This code was written in Visual Basic for Applications (VB, VBA) for Microsoft Access 2002 (XP) on Windows XP.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s