You don't form longterm memories while asleep; you lose the last few minutes before you drop off, as well. Short-term memories are held, but they don't get stored.
And the same applies while you're dreaming - nothing's getting recorded. You can pull it out of short-term right after you wake up, but that fades right out.
When you do remember dreams, it's because you remember remembering them while you were awake. If it was vivid enough to go over hard enough, then the second-hand memory gets stored.