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:

  • The record variable’s length differs from the length specified in the corresponding Open statement. Make sure the sum of the sizes of fixed-lengthvariables in theuser-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)


  • The variable in a Put statement is (or includes) a variable-length string. 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.

  • The variable in a Put statement is (or includes) a Variant. 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.

[efb_likebox fanpage_url="" box_width="840" box_height=340"" responsive="1" show_faces="1" show_stream="1" hide_cover="1" small_header="0" hide_cta="0" locale="en_US"]