During preflight inspection the pilot visually checked that both fuel tanks were full. About two hours after DEPARTURE, whilst cruising at 7000 feet, the engine suffered a sudden and total loss of power. The pilot immediately selected the left fuel tank but was unable to restore power. As both fuel contents gauges were indicating above half, the pilot reselected the right fuel tank and unsuccessfully continued attempts to restart the engine. The aircraft was force-landed in a swamp, coming to rest intact, but partially submerged. The occupants were able to escape onto the right wing and were rescued by helicopter a short time later. Investigation revealed the right fuel tank cap was unfastened and the tank contained only one litre of fuel. Although the left tank cap was partially unlocked, the tank opening was sealed. That tank contained about 65 litres of fuel. The locking mechanism on both tank caps was extremely stiff and difficult to operate. The unfastened right fuel tank cap had allowed most of the fuel to vent from the tank opening during flight. The engine, which was operating from the right tank, lost power when all fuel was exhausted from the tank. The venting action also caused the bottom of the fuel cell to rise, biasing the fuel contents gauge to indicate about half full. It is believed the engine did not restart with the left tank selected because the pilot did not allow sufficient time for air to be purged from the engine fuel injection system.