The length of a record variable in a Get or Put statement must be the length specified in its corresponding Open statement. This error has the following causes and solutions:
Make sure the sum of the sizes of fixed-length variables in the user-defined type defining the record variable's type is the same as the value stated in the Open statement's Len clause. In the following example, assume RecVar
is a variable of the appropriate type. You can use the Len function to specify the length, as follows:
Open MyFile As #1 Len = Len(RecVar)
Because a 2-byte descriptor is always added to a variable-length string placed in a random access file with Put, the variable-length string must be at least 2 characters shorter than the record length specified in the Len clause of the Open statement.
Like variable-length strings, Variant data types also require a 2-byte descriptor. Variants containing variable-length strings require a 4-byte descriptor. Therefore, for variable-length strings in a Variant, the string must be at least 4 bytes shorter than the record length specified in the Len clause.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).