ACC2000: Saving Long Expression in SQL View Causes Access to Quit

ID: Q241194


The information in this article applies to:
  • Microsoft Access 2000

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

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


SYMPTOMS

In SQL view of a query, if you try to save a long SQL statement, you see one of the following behaviors.

In Windows 95 or 98

You may receive the following error message:
This program has performed an illegal operation and will be shut down.

If the problem persists, contact the program vendor.
When you click Details, the following message appears:
MSACCESS caused an invalid page fault in MSACCESS.EXE at 0167:300ec09b.
NOTE: The actual memory address may vary.

In Windows NT

Access suddenly quits without error.


CAUSE

In SQL view, you tried to save a query that contains a criteria or an expression that has more than 511 characters.


RESOLUTION

To work around this problem, do not try to edit a criteria or an expression of an existing query in SQL view if the criteria or expression has more than 511 characters.

If you do want to create a query with a criteria or an expression that has more than 511 characters, use the CreateQueryDef method in a Visual Basic for Applications procedure. The following example illustrates how to do this.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

  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:


  4. 
    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 
  5. In the Immediate window, type the following line, and then press ENTER:


  6. CreateLongQuery
A new query called LongExpQuery appears in Access.

To make changes that require a criteria or an expression that has more than 511 characters, create a new query with the changes that you need by once again using the CreateLongQuery procedure.

You can run the query that you created in this example, but you cannot edit its expression in the query design grid if it has more than 511 characters. For additional information about this issue, click the article number below to view the article in the Microsoft Knowledge Base:
Q239565 ACC2000: Query Expression Truncated at 511 Characters


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

NOTE: This behavior only happens with a criteria or an expression inside the SQL statement. Other parts of a SQL statement or the SQL statement as a whole can have more than 511 characters.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb, and then create a new query.


  2. On the View menu, click SQL.


  3. Type or paste a SQL statement that contains an expression that has more than 511 characters, such as the following:


  4. 
       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; 
  5. In SQL view, on the File menu, click Save.


Note that you see one of the behaviors mentioned in the "Symptoms" section.

Additional query words: pra ipf gpf

Keywords : kberrmsg kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: January 7, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.