ACC2000: Invalid Length for Fixed-Length String - Exceeds 64-KB Limit (210172)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q210172
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you declare a fixed-length string variable that is larger than 65,535 bytes, the following message appears:
Compile error:

Invalid length for fixed-length string

CAUSE

Variables in Microsoft Access 2000 are limited to approximately 64 KB per fixed-length string, regardless of whether the variables are local or global. The error message appears if a fixed-length string exceeds that limit.

This is not a cumulative total. In other words, variable X and variable Y can each be approximately 64 KB in size. The exact maximum length of a fixed-length string in Microsoft Access 2000 is 65,535 bytes.

RESOLUTION

Do not declare fixed-length strings longer than 65,535 bytes.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Microsoft Access and open any database or project.
  2. Create a module and type the following lines in the Declarations section:
    Option Explicit
    Global x as String * 66000
    						
    You then see the following error message:
    Compile error:

    Invalid length for fixed-length string
    NOTE: The error message appears only if you type the code, not if you cut and paste it into the code window.

  3. Click OK, and then change the string length to 65535; this is the maximum allowable length.
This limit also applies to fixed-length strings declared within procedures, and the same message appears if it is exceeded.

REFERENCES

For more information about the String data type, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type string data type in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kberrmsg kbprb kbprogramming KB210172