We can identify with the frustration at losing your work, but perhaps your
question goes beyond the immediate frustration to the longer term. Here's a
suggestion if you are genuinely asking, "How can I avoid this from happening
again?"
Firstly, there's just a slight chance that you may be able to find the
missing module by locating an odd name in this query:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE MSysObjects.Type = -32761
ORDER BY MSysObjects.Name;
Sometimes you can identify a temp module there, and find your code again.
Probably not if you already compacted.
Anyway, suggestions on how you can use Access reliably.
Make sure Name AutoCorrect is off.
From main Access window:
Tools | Options | General
Make sure Compile on Demand is off.
From VBA window:
Tools | Options
Don't edit code in break mode. Just as you cannot go plugging more RAM chips
into your computer while it is running, you cannot go stuffing more code
into your module while the code is running.
I wasn't clear from your post whether you created a new form, or a new
instance of a form with the New keyword. Editing while an instance is open
would be inviting disaster.
Backup every few hours - typically 3 times a day (when you stop for lunch,
dinner, and sleep), without overwriting previous backups.
Compact *after* each backup. This leaves you the uncompacted backup in case
something goes wrong. (Doubly important in A2007.)
Decompile periodically - typically after the final compact at the end of
each day's heavy development, but sooner if there is any indication that
something is not right. Then compact again.
At the end of each day's development, copy the backup file to another
location (different computer, USB memory stick, ...), again without
overwriting previous backups.
Before any major change, copy the code out to Notepad, and you can easily go
back if it doesn't work out.
If something does go wrong, make a copy of the file before trying to fix it.
That way, you get multiple goes at solving the problem.
Maybe that all sounds rather basic, but it's just the voice of experience.
I've lost stuff in the past, but it's been years now since I've lost more
than a couple of hours worth of work.
Hope you're feeling less frustrated by the time you read this, and that it
doesn't come across as merely closing the gate after the horse escaped. It's
intended as the voice of experience, addressing your question of how you can
use Access as a reliable development tool.