Hi Tim
I had the same problem on my old Bailey RANGER 460/4 2006 model
The lock on the Bailey battery boxes is held in by small pastic fingers but odd ones break making the lock fall out or it becomes loose the cause is using wd-40 or simlar which makes the plastic soft and the fingers break. You have 2 choices to repair the lock first is the cheapest is to remove the lock and you will see a groove around the barrel of the lock which you need get a circlip to fit in the groove of the lock. On the battery box door you well see the plastic fingers which hold the lock in they will need to be cut off flush then all you do is slide the lock back in and secure the lock with the circlip this should cost less than a £1.
The other way is to buy a new battery box door frame at a cost of £50 plus if you wish to go down that way the company who makes the the battery door frame for Bailey is B C A Leisure and there address is
B C A Leisure Unit H9 Premier Way Lowfeilds business Park Elland HX5 9HF Tel 01422-376977
They will only supply the bare door frame which comes with a circlip in case the plastic fingers break later.
I just brought a circlip and cut the plastic fingers off and fitted the circlip.
I hope this is some help
Chris