
Microsoft Access VBA Error 9: Fixing Subscript Out of Range
transcript
show notes
Run-time error 9, "Subscript out of range," usually means VBA is trying to access something that does not exist. Often it is an array position outside its valid range, but it can also involve missing collection items or keys.
This episode explains what a subscript is, why indexes can be too high or too low, and why zero-based arrays created with VBA's Array function are a common source of off-by-one mistakes. Three values might sound like positions 1 through 3, but VBA may actually number them 0 through 2.
Learn how to use LBound and UBound instead of hard-coding loop limits, how to inspect the failing line in the VBA editor, and why "On Error Resume Next" is not a real repair. It is less like fixing the engine and more like covering the check-engine light with tape.





