If it's the two button type and it was originally with the car (rather than a replacement, which would need coding professionally) then you should be able to get it working again if you replace the battery, hold it near the car, and press the "lock" button repeatedly until the indicators flash.
These remotes have a number of codes that they cycle through to confuse anyone attempting to intercept the code. This is why you sometimes can't unlock the car straight away - the button was pressed in your pocket causing the car and remote to go out of synch.