I've got a solution for this one DeKock!
Ok... do the following.. You might have to do it a couple of times because it kinda needs to be done in a sistematic sequence so don't bang the steering wheel like I did after first 2 times failure!!

I had the EXACT problem you are having - with my 540 AND my 535. (Urm... your 540 is E39??? Dunno if it will work with other platforms)
(Lesson 1 - NEVER EVER "play around" with your keys' buttons around your car because you might just have a problem afterwards with the locking system! BELIEVE it!)
1) Sit in your car and make sure the radio and lights are OFF. Doors and windows CLOSED.
2) Open the driver's door.
3) Close the drivers's door and put the key in the ignition and turn the IGNITION on. The rooflight will now be on.
4) When the rooflight dies count about 6 seconds then take the key out and press the unlock button and KEEP it in while doing the following in nr 5!
5) Push the lock button 3 times for about a full second and after the third time let go of the lock and unlock buttons at the same time!
6) CLICK-CLICK-CLICK!! is what you should hear and your locksystem should now be "reset".
This is all assuming that your key's battery is working and that it transmits a signal. But TRY this... very good chance it's just the system that's bit deurmekaar!:thumbsup: