What happens when we know that there is something that we forgot but we can't remember what it was?
It is a phenomenon known as room amnesia, some research has shown that your brain may use physical barriers like the room and doorways as a way to compartmentalize thoughts.
One article summarizes it here:


  The researchers say that when you pass through a doorway, your mind
  compartmentalizes your actions into separate episodes. Having moved
  into a new episode, the brain archives the previous one, making it
  less available for access. It’s as if you slam a mental door between
  what you knew and…what was I saying?


This is the research.