Nissan Micra (X reg) - Headlamp stops working randomly - Chris S

This seems to happen at random:

The main beam warning light will come on and the driver's side headlamp (main and dipped beam) will stop working. The sidelights and passenger side headlamp will carry on working normally.

Then suddenly the main beam warning light will go off and both headlamps will work normally, as will the warning light.

Does anybody have any ideas please?