There is a item in your code that has not been declared yet such as a variable or object - this most often happens due to a typing error on your part . When the Error is detected, you should be pointed directly to the source of the problem (highlighted) if you select the [Debug] button from the Error message window. If not...then use the Compile And Save All Modules menu item located under the Debug menu. This will stick a nail right onto the problem spot (..so to speak).
Compile and Save will actually run through the code to test if it is OK without all the other Access overhead (so to speak) such as opening and displaying Forms, etc.. The auto-syntax checking does not pick up coding errors such declarations, non closed While, With, Select, If, etc., statements. Running the code picks up those errors.