Microsoft KB Archive/224349

From BetaArchive Wiki

Article ID: 224349

Article Last Modified on 1/24/2007



APPLIES TO

  • Microsoft Access 97 Standard Edition



This article was previously published under Q224349


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


SYMPTOMS

On pages 35 through 37 of the Building Applications with Microsoft Access 97 manual, there is a discussion titled "Working with Command Bars in Code." If you try to implement the code within this section of the manual, you may receive the following error message:

Compile error:

User-defined type not defined.

CAUSE

The Building Applications with Microsoft Access 97 does not explain that in order for the code to work, you must create a reference to the necessary external library.

RESOLUTION

Reference the Microsoft Office 8.0 Object Library. To do this, open your code module in Design view, and then on the Tools menu, click References. Scroll down the list of references until you find Microsoft Office 8.0 Object Library. Click to select the check box for this reference, and then click OK to close the References dialog box.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. In a new database, create a new module.
  2. On the Tools menu, click References and note that the three default references associated with a new database are:

    Visual Basic For Applications
    Microsoft Access 8.0 Object Library
    Microsoft DAO 3.5 Object Library

    Click Cancel to close the References dialog box.
  3. In the new module, type or paste the following sample code provided by the Building Applications with Microsoft Access 97 manual:

    Option Compare Database
    Option Explicit
    
    Private Sub AddInvoiceCommand()
        Dim cb As CommandBar
        Dim ctl As CommandBarControl
        
        'Set a reference to the Tools menu.
        Set cb = CommandBars!Tools
        
        'Create new CommandBarControl object on the Tools menu and
        'set a reference to it.
        Set ctl = cb.Controls.Add(Type:=msoControlButton)
        
        'Set properties of the new command.
        With ctl
            .BeginGroup = True
            .Caption = "Print Invoice"
            .FaceID = 0
            .OnAction = "=PrintInvoice()"
            .Visible = False
        End With
    End Sub
                        
  4. Try to compile the code. Note that you receive the error message mentioned in the "Symptoms" section of this article.


REFERENCES

For additional information about referencing libraries, click the article number below to view the article in the Microsoft Knowledge Base:

175484 ACC97: References That You Must Set When You Work with Microsoft




Keywords: kbprb KB224349