I was able to fix the error by
- Completely closing Access
- Renaming the database file
- Opening the renamed database file in Access.
- Accepted various security warnings and prompts.
- Not only did I choose to Enable Macros, but also accepted to make the renamed database a Trusted Document.
- The previous file had also been marked as a Trusted Document.
- Successfully compile the VBA project without error, no changes to code.
- After the successful compile, I was able to close Access again, rename it back to the original filename. I had to reply to the same security prompts, but once I opened the VBA project it still compiled without error.
A little history of this case and observations:
- I'm posting this answer because my observed symptoms were a little different than others and/or my solution seems unique.
- At least during part of the time I experienced the error, my VBA window was showing two extra, "mysterious" projects. Regrettably I did not record the names before I resolved the error. One was something like ACXTOOLS. The modules inside could not be opened.
- I think the original problem was indeed due to bad code since I had made major changes to a form before attempting to update its module code. But even after fixing the code the error persisted. I knew the code worked, because the form would load and no errors. As the original post states, the “User-defined type not defined” error would appear but it would not go to any offending line of code.
- Prior to finding this error, I ensured all necessary references were added. I compacted and repaired the database more than once. I closed down Access and reopened the file numerous times between various fix attempts. I removed the suspected offending form, but still got the error. I tried other various steps suggested here and on other forums, but nothing fix the problem.
- I stumbled upon this fix when I made a backup copy for attempting drastic measures, like deleting one form/module at a time. But upon opening the backup copy, the problem did not reoccur.