Error 63, “Bad record number”, fires when a Get or Put is given a record number that cannot be used: zero, negative, or beyond the range the file and mode permit. Records in VBA random access are numbered from 1, and a surprising share of error 63s are off-by-one bugs where an index counted from 0 (an array index, a list position) was used directly as a record number. The file is not corrupt; the address handed to the read or write is invalid.
recNo = listBox.ListIndex + 1 ' ListIndex is 0-based; records are 1-based Get #fn, recNo, rec ' without the +1, the first item is error 63
LOF(fn) \ recordLength. A requested number above the count on a Get, or below 1 anywhere, should be rejected with a clear message before the statement runs.If the number is in range and error 63 persists, verify the file was opened For Random and not For Binary (binary access uses byte positions, and the same number means a different thing), and confirm the record number variable is not overflowing: a Long computation stored into an Integer wraps into a negative, invalid number.
Why is record 0 invalid? VBA numbers random-access records starting at 1. Zero is reserved in Get and Put to mean “the next record after the current position,” so passing a literal 0 from a 0-based index is both common and wrong.
Can error 63 mean the file is corrupt? Not by itself. It reports an invalid address for the operation. Corruption shows up as wrong data read successfully, or as error 59 when record boundaries stop lining up.