ACC97: Error When You Click a Custom Command Bar Button

ID: Q193167


The information in this article applies to:

Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

When you click a menu or button on a command bar, you may see the following error message:

The expression you entered has a field, control or property name that Microsoft Access can't find.


CAUSE

This problem happens when the database has a long file name, and you assign a function using the following syntax:


   .OnAction = "=<function name>()" 


RESOLUTION

Do not include an equal sign (=) and parentheses (()) when you assign the function to the OnAction property of the command bar. For example, assign the OnAction property using the following syntax:


   .OnAction = "<function name>" 


STATUS

Microsoft has confirmed this to be a problem in Microsoft Access 97.


MORE INFORMATION

Steps to Reproduce Problem

  1. Create a new database named Db1.mdb.


  2. Insert a new module, and then create a reference to Microsoft Office 8.0 Object Library.


  3. Type the following line in the Declarations section if it is not already there:


  4. 
          Option Explicit 
  5. Type the following procedures:


  6. 
           Sub Test()
    
              Dim MBar As CommandBar
              Dim MBarItem As CommandBarControl
    
              Set MBar = CommandBars.Add(Name:="Test Bar")
              MBar.Visible = True
              Set MBarItem = MBar.Controls.Add(Type:=msoControlButton)
              With MBarItem
                .Caption = "Test"
                .Style = msoButtonCaption
                .OnAction = "=RunMe()"
              End With
    
           End Sub
    
           Function RunMe()
              MsgBox "You pressed a toolbar button!"
           End Function 
  7. On the File menu, click Save. Type Module1 in the Save As dialog box, and then click OK.


  8. To test this function, type the following line in the Debug window, and then press ENTER:


  9. Test
    A new menu bar should appear.
  10. On the Test menu bar, click Test. You should get a message box that reads "You pressed a toolbar button!" Click OK.


  11. On the File menu, click Exit.


  12. Open Windows Explorer and change the name of the file to This is a long file name.mdb.


  13. Open the "This is a long file name.mdb" file.


  14. On the Test menu bar, click Test. You should receive the error message mentioned in the "Symptoms" section.


Additional query words: pra


Keywords          : kberrmsg kbdta MdlGnrl 
Version           : WINDOWS:97
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 13, 1999