ACC: How to Change the "Microsoft Access" Window Caption 1.x/2.0

Last reviewed: June 8, 1997
Article ID: Q95932
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

Microsoft Access does not have property to set the main caption of the Microsoft Access window. To change the default "Microsoft Access" caption to your own text, you must call the Windows application programming interface (API) SetWindowText() function.

MORE INFORMATION

To change the default "Microsoft Access" caption to your own text string, create a new module in Microsoft Access and add the following function with the appropriate declaration section.

NOTE: You may have some Microsoft Windows API functions defined in an existing Microsoft Access library; therefore, your declarations may be duplicates. If you receive a duplicate procedure name error message, remove or comment out the declarations statement in your code.

NOTE: In the following sample code, an underscore (_) is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.

      '-----------------------------------------
      ' GLOBAL DECLARATION
      '-----------------------------------------
      Option Compare Database
      Option Explicit
      Declare Function FindWindow% Lib "User" (ByVal lpClassName As Any, _
                          ByVal lpWindowName As Any)
      Declare Sub SetWindowText Lib "User" (ByVal hWnd%, ByVal lpString$)

      '-----------------------------------------
      ' Function: SetCaption ()
      ' This function will set the caption of
      ' Microsoft Access's main window.
      '-----------------------------------------
      Function SetCaption ()
         Dim hWnd%
         hWnd% = FindWindow%("OMain", 0&)
         Call SetWindowText(hWnd%, "This is cool!")
      End Function

To change the caption when Microsoft Access starts, you can run the RunCode macro action with SetCaption() as an argument and save the macro as AutoExec. When you open this database, this macro will run and change the "Microsoft Access" caption to "This is cool!"

REFERENCES

"Microsoft Windows Software Development Kit Programmer's Reference Volume 2: Functions," version 3.1


Additional query words: windows api
Keywords : kbprg PgmApi
Version : 1.0 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.