Flexible coding in forms allows developers to write reusable and maintainable code by avoiding hard-coded object names. This is done through the use of system variables that reference the current cursor object, and built-in functions that get and set object properties and find an object's internal ID at runtime. Object IDs can then be stored in variables and used to reference objects within a code block instead of their names. This makes the code more flexible and generic.