Microsoft KB Archive/210172

= ACC2000: Invalid Length for Fixed-Length String - Exceeds 64-KB Limit =

Article ID: 210172

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



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.



Steps to Reproduce Behavior
 Start Microsoft Access and open any database or project.  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.

 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.

