Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

OFF2000: Run-Time Error 3085 Using DAO


View products that this article applies to.

Symptoms

When you use Data Access Objects (DAO) in a Microsoft Office program to open a Microsoft Access query, you may receive the following error message:
Run-time error '3085':
Undefined function <function name> in expression.

↑ Back to the top


Cause

You are using DAO to open a query that contains a user-defined function.

↑ Back to the top


More information

When using DAO, you can refer to Microsoft Jet objects that are dependent only on other Microsoft Jet objects.
The following steps demonstrate this problem. The steps create a query in Microsoft Access that calls a user-defined function and then tries to open a recordset on that query using DAO in Microsoft Excel.

Steps to Reproduce Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Open the sample database Northwind.mdb.
  2. Create a module and type the following procedure:
    Function IsInternational(strCountry As String) As String
       If strCountry = "USA" Then
          IsInternational = "Local"
       Else
          IsInternational = "Intl"
       End If
    End Function
    					
  3. Create a new query based on the Customers table as follows:
       Query: qryExcelTest
       --------------------------------------
       Type: Select Query
    
       Field: CompanyName
          Table: Customers
       Field: Country
          Table: Customers
       Field: Expr1: IsInternational([Country])
    					
  4. Quit Microsoft Access.
  5. In Microsoft Excel, create a new workbook.
  6. On the Tools menu, point to Macros, and then click Visual Basic Editor.

    In the Visual Basic Editor, insert a new module sheet by clicking Module on the Insert menu. Type the following sample macro (Sub procedure).
    Sub xlTest()
       Dim db As Database, rs1 As Recordset
       Dim qry As QueryDef
       Set db = Workspaces(0).OpenDatabase _
         ("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb")
         ' Replace the above path with the correct path to the
         ' sample Northwind.mdb database on your computer.
       Set qry = db.QueryDefs("qryExcelTest")
       Set rs1 = qry.OpenRecordset
       rs1.MoveLast
       rs1.Close
       db.Close
    End Sub
    					
  7. On the Tools menu, click References. Click to select the Microsoft DAO 3.6 Object Library check box, and then click OK.
  8. Run the macro called xlTest.

    Note that you receive the error message mentioned in the "Symptoms" section of this article.

↑ Back to the top


Keywords: KB209864, kbprb, kbprogramming, kberrmsg

↑ Back to the top

Article Info
Article ID : 209864
Revision : 2
Created on : 6/28/2004
Published on : 6/28/2004
Exists online : False
Views : 450