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

ID: Q95932


The information in this article applies to:


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 
Version           : 1.0 1.1 2.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: March 18, 1999