Microsoft KB Archive/239565

From BetaArchive Wiki

Article ID: 239565

Article Last Modified on 11/25/2002



APPLIES TO

  • Microsoft Access 2000 Standard Edition



This article was previously published under Q239565

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

This article applies only to a Microsoft Access database (.mdb).


SYMPTOMS

In a Microsoft Access 2000 query, when you try to edit the query in the query design grid, you may receive the following error message:

The expression you entered is missing a closing parenthesis, bracket (]), or vertical bar (|).

You then notice that an expression or a critera has been truncated.

Upon saving the query, you may also see the following error message:

Missing ),] or Item in query expression '<expression>'.

CAUSE

An expression or a criteria in your query is over 511 characters in length. Although Access 2000 Help states that a cell in a query design grid has a limit of 1024 characters, the Access 2000 query design interface actually has a limit of 511 characters. This issue does not occur in earlier versions of Microsoft Access.

RESOLUTION

To resolve this problem, obtain Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a).

To obtain SR-1/SR-1a, click the article number below to view the article in the Microsoft Knowledge Base:

245025 OFF2000: How to Obtain and Install Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a)


To temporarily work around this problem, do not try to edit an expression of an existing query in Design view if your SQL statement has more than 511 characters.
If you want to create a query with an expression that exceeds 511 characters, you can use the CreateQueryDef method in a Visual Basic for Applications procedure. The following example illustrates how to do this with the example from the "Steps to Reproduce Problem" section:

  1. Open the sample database Northwind.mdb.
  2. Click Modules under Objects, and then click New.
  3. In the new module type the following code:

    Option Compare Database
    
    Sub CreateLongQuery()
    
       Dim db1 As DAO.Database
       Dim qdfNew As DAO.QueryDef
    
       Set db1 = CurrentDb
    
       With db1
          Set qdfNew = .CreateQueryDef("LongExpQuery", _
             "SELECT Employees.EmployeeID, [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] & [Employees]![Lastname] & " _
             & "[Employees]![Lastname] AS Expr1 FROM Employees;")
          .Close
       End With
    
       Application.RefreshDatabaseWindow
    
    End Sub
                        
  4. In the Immediate window, type the following line, and then press ENTER:

    CreateLongQuery
                        

A new query called LongExpQuery appears in Access.

The query that you created in this example can be run, but its expression cannot be edited through the interface if it has more than 511 characters. To make changes that require an expression greater than 511 characters, create a new query with the changes you need by once again using the CreateLongQuery procedure.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Office 2000 SR-1/SR-1a.

MORE INFORMATION

If the query has been imported or converted from an earlier version of Access, it will run but you cannot edit it in Design view.

Steps to Reproduce Problem

  1. Open the sample database Northwind.mdb.
  2. Create a new query and add the following field:

       Field: EmployeeID
       Table: Employees
                        
  3. In the Field line of the next column, type the following expression:

       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname] & 
       [Employees]![Lastname] & [Employees]![Lastname]
                        
  4. On the Query menu, click Run.

    Note that you receive the following error:

    Missing ),] or Item in query expression '<expression>'.



Additional query words: pra cut off clipped

Keywords: kberrmsg kbbug kbpending KB239565