How To Recode A Door Lock

I have a car where the driver door will lock with the key, but not by locking it and holding the handle, and it will open with the handle when locked. Is this the solution?