- Save this code into a new module called FormHelper.
- 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.